Int
- whole numbers, will auto use 64-bit if available
Float
- always a 32-bit decimal
- 6 decimal place precision
Double
- 64-bit decimal (default for decimal inference)
- 15 decimal place precision
- swift does not allow overflow (going beyond the range) by default
Declaration
// declaration - create but don't initialize<br>
var myVariable1: Int
// declaration - create/init with 0 value
var myVariable2 = Int()
// create and initialize with an initial value (preferred)
var myVariable3 = 24
// create multiple variables
var yes = 0, no = 0
Notation
// -> 51 prefix with 0b<br>
let binaryNotation = 0b110011<br>
// -> 10 prefix with 0o<br>
let octalNotation = 0o12<br>
// -> 50 prefix with 0x<br>
let hexadecimalNotation = 0x32<br>
// -> suffix with e-<br>
let scientificNotation = 4.4e-7<br>
// optional _ = easier to read<br>
let longNumber = 1_000_000<br>