Basics: Numeric Type Conversion
Use the Int type for all general-purpose integer constants and variables in your code, even if they’re known to be nonnegative.
Use other integer types only when they’re specifically needed for the task at hand, because of explicitly sized data from an external source, or for performance, memory usage, or other necessary optimization.
Integer Conversion
The range of numbers that can be stored in an integer constant or variable is different for each numeric type.
Let cannotBeNegative: UInt8 = -1
// UInt8 cannot store negative numbers, and so this will report an error
let tooBig: Int8 = Int8.max + 1
// Int8 cannot store a number larger than its maximum value,
// and so this will also report an error Let twoThousand: UInt16 = 2_000
let one: UInt8 = 1
let twoThousandAndOne = twoThousand + UInt16(one)
Semantic portal