An integer is a complete number that has no fractional part, such as 42 and-23. Integers are either signed (integers, 0, or negative numbers) or unsigned (positive or 0).
Swift provides 8-bit, 16-bit, 32-bit, and 64-bit signed and unsigned integers. These integers are named in a similar way to C, with a 8-bit unsigned integer uint8,32 signed integer Int32. Like all types in swift, these integer-type names are capitalized first.
Range of integers
You can access the minimum and maximum values that each integer type can represent by two properties Min and max of an integer type:
Let MinValue = uint8.min//minvalue = 0
Let MaxValue = Uint8.max//maxvalue = 255
The values of these two properties of a numeric type return their appropriate size ranges, so they can also be used for other expressions of the same type.
Int
In most cases, it is not necessary in your code to pick a full-sized integer to use. Swift provides an additional integer type, Int, which is the same size as your current local platform environment:
Under a 32-bit platform, the size of Int is the same as Int32
Under a 64-bit platform, the size of Int is the same as Int64
Unless you need to work with a full-size integer, all other cases use int to create an integer value. This helps your code to be compatible with each other and interoperate. On a 32-bit platform, int can store values between 2147483648 and 2147483647, which is already large enough for the range of many integers.
UInt
Swift also provides an unsigned integer type, UInt, which can also be of the same size as the current local platform:
In a 32-bit platform, the size of the UInt is the same as UInt32
In a 64-bit platform, the size of the UInt is the same as UInt64
Note: UINT is used for situations where you need an unsigned integer that is the same size as the local platform. If this is not the case, it is preferable to use int, even if you do not know the size of the values stored on the local platform. Insisting on using int to represent an integer value helps the code interoperate, avoids conversions between two different numeric types, enables the integer type to infer the match automatically, and describes in detail in the type safety and type inference sections
Swift's integer