let minIntValue = Int.min
let maxIntValue = Int.max
println("minIntValue = \(minIntValue),maxIntValue = \(maxIntValue)")
//當前輸出結果是:minIntValue = -9223372036854775808,maxIntValue = 9223372036854775807
let minInt8Value = Int8.min
let maxInt8Value = Int8.max
println("minInt8Value = \(minInt8Value),maxInt8Value = \(maxInt8Value)")
//當前輸出結果是:minInt8Value = -128,maxInt8Value = 127
let minUInt8Value = UInt8.min
let maxUInt8Value = UInt8.max
println("minUInt8Value = \(minUInt8Value),maxUInt8Value = \(maxUInt8Value)")
//當前輸出結果是:minUInt8Value = 0,maxUInt8Value = 255
在Swift裏是以十進制輸出的:
let decimalInt = 20 //十進制數
let binaryInt = 0b1100 //0b前綴爲二進制數,轉換結果爲12
let octalInt = 0o21 //0o前綴爲八進制數,轉換結果爲17
let hexInt = 0x11 //0x前綴爲十六進制數,轉換結果爲17
2.可讀性:用下劃線來(_)分割數字
let va5 = 12_000_000 //結果相當於12000000
let va6 = 1_000_000.000_000_1 //結果相當於1000000.0000001