Unsigned literal

How do you create an UInt64 in julia? The same effect that can be achieved by 0ull for the number 0 in C++.

julia> UInt64(0)
0x0000000000000000
3 Likes

You can enter UInt64 literals by writing out the numbers in hexadecimal with at least 9 digits (with 8 digits, it would be an UInt32 literal):

julia> 0x00000000 # UInt32
0x00000000

julia> 0x000000000 # UInt64
0x0000000000000000
2 Likes

Beware to not go to up to 17 for UInt128 or 33 for BigInt. For that reason e.g. UInt64(0) is less likely to be surprising.

1 Like