Structure

Int

A signed integer value type.

Overview

On 32-bit platforms, Int is the same size as Int32, and on 64-bit platforms, Int is the same size as Int64.

Symbols

Initializers

init()

Create an instance initialized to zero.

init(NSNumber)init(CGFloat)
init(Float)

Creates a new instance by rounding the given floating-point value toward zero.

init(Double)

Creates a new instance by rounding the given floating-point value toward zero.

init(Int32)init(UInt16)init(Int)init(UInt64)init(UInt)init(UInt8)init(Int64)init(Int16)
init(Float80)

Creates a new instance by rounding the given floating-point value toward zero.

init(Int8)init(UInt32)
init?(String, radix: Int)

Construct from an ASCII representation in the given radix.

init(bigEndian: Int)

Creates an integer from its big-endian representation, changing the byte order if necessary.

init(bitPattern: UInt)

Construct a Int having the same memory representation as the UInt bitPattern. No range or overflow checking occurs, and the resulting Int may not have the same numeric value as bitPattern–it is only guaranteed to use the same pattern of bits.

init<U>(bitPattern: UnsafeMutablePointer<U>?)init<U>(bitPattern: UnsafePointer<U>?)init(bitPattern: OpaquePointer?)
init(bitPattern: ObjectIdentifier)

Creates an integer that captures the full value of the given object identifier.

init(bitPattern: UnsafeMutableRawPointer?)init(bitPattern: UnsafeRawPointer?)init?(exactly: UInt8)init?(exactly: Int16)init?(exactly: Int64)init?(exactly: UInt)init?(exactly: UInt32)init?(exactly: Int)init?(exactly: Int32)init?(exactly: UInt64)init?(exactly: Int8)init?(exactly: UInt16)
init?(exactly: Double)

Creates a Int whose value is value if no rounding is necessary, nil otherwise.

init?(exactly: Float)

Creates a Int whose value is value if no rounding is necessary, nil otherwise.

init?(exactly: Float80)

Creates a Int whose value is value if no rounding is necessary, nil otherwise.

init(integerLiteral: Int)

Create an instance initialized to value.

init(littleEndian: Int)

Creates an integer from its little-endian representation, changing the byte order if necessary.

init(truncatingBitPattern: UInt64)

Construct a Int having the same bitwise representation as the least significant bits of the provided bit pattern.

init(truncatingBitPattern: Int64)

Construct a Int having the same bitwise representation as the least significant bits of the provided bit pattern.

Instance Properties

var bigEndian: Int

Returns the big-endian representation of the integer, changing the byte order if necessary.

var byteSwapped: Int

Returns the current integer with the byte order swapped.

var customMirror: Mirror

A mirror that reflects the Int instance.

var customPlaygroundQuickLook: PlaygroundQuickLook
var description: String

A textual representation of self.

var hashValue: Int

The hash value.

var littleEndian: Int

Returns the little-endian representation of the integer, changing the byte order if necessary.

Type Properties

Instance Methods

func advanced(by: Int)func distance(to: Int)
func toIntMax()

Represent this number using Swift’s widest native signed integer type.

Type Methods

static func addWithOverflow(Int, Int)

Add lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

static func divideWithOverflow(Int, Int)

Divide lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

static func multiplyWithOverflow(Int, Int)

Multiply lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.

static func remainderWithOverflow(Int, Int)

Divide lhs and rhs, returning the remainder and a Bool that is true iff the operation caused an arithmetic overflow.

static func subtractWithOverflow(Int, Int)

Subtract lhs and rhs, returning a result and a Bool that is true iff the operation caused an arithmetic overflow.