If you want to explicitly control the size of the variable used, you can specify one of the various integer types available:
On 32-bit systems, Int is the same as Int32 , while on 64-bit systems, Int is the same as Int64 .
On 32-bit systems, UInt is the same as UInt32 , while on 64-bit systems, UInt is the same as UInt64 .
The following code snippet prints the range of numbers representable for each integer type:
print("UInt8 - Min: \(UInt8.min) Max: \(UInt8.max)") print("UInt16 - Min: \(UInt16.min) Max: \(UInt16.max)") print("UInt32 - Min: \(UInt32.min) Max: \(UInt32.max)") print("UInt64 - Min: \(UInt64.min) Max: \(UInt64.max)") print("Int8 - Min: \(Int8.min) Max: \(Int8.max)") print("Int16 - Min: \(Int16.min) Max: \(Int16.max)") print("Int32 - Min: \(Int32.min) Max: \(Int32.max)") print("Int64 - Min: \(Int64.min) Max: \(Int64.max)")
For integer type, the min property returns the minimum number and the max property returns the maximum number.