In golang, both uint64
and float64
are 8 bytes in size. I expected that the maximum number represented in uint64 (which would be 1<<64 - 1
, all bits set to 1
) would be greater or at least equal to the maxium number represented for float64
which, being made up with sign, exponent and mantissa, I expected it to be lesser.
Link to playground: https://go.dev/play/p/ZbVYKmTV3CW
CodePudding user response:
The reason is simple: the exponent in float64
can be 64 or higher, up to 1023.