Kha*_*azi 5 read-eval-print-loop swift swift-playground
使用Swift,在终端或游乐场中,当我在新行上输入以下内容时:
UInt64.max
Run Code Online (Sandbox Code Playgroud)
我得到的结果值为-1.
这是一个错误吗?
编辑:示例
$ xcrun swift
Welcome to Swift! Type :help for assistance.
1> UInt64.max / 2
$R1: UInt64 = 9223372036854775807
2> UInt64.max / 2 + 1
$R2: UInt64 = -9223372036854775808
3> UInt64.max
$R3: UInt64 = -1
4> println(UInt64.max / 2)
9223372036854775807
5> println(UInt64.max / 2 + 1)
9223372036854775808
6> println(UInt64.max)
18446744073709551615
Run Code Online (Sandbox Code Playgroud)