Why is UInt64.max limited to 9,223,372,036,854,775,807? According to Apple's documentation it should be 264-1 = 18,446,744,073,709,551,615.
Why is UInt64.max limited to 9223372036854775807?
Where do you get this ?
I tried in playground:
print(UInt64.max)and got
18446744073709551615
I could also assign the value
let xMax : UInt64 = 18446744073709551615But, of course, it is different with Int64
print(Int64.max)gets
9223372036854775807
and assigning
let yMax : Int64 = 18446744073709551615results in an error
error: integer literal '18446744073709551615' overflows when stored into 'Int64'
Because in that case, it has to range from negative to positive:
from -9223372036854775808 to +9223372036854775807 (from -263 to +263-1)
Yes, the error occurs in my playground:
It seems the value of max is correct but the playground sideview is showing an incorrect value.