nkey = (1<<63)-333
fkey = nkey + 0.0
Now, of course, nkey == fkey by the Lua rules of converting both to floats before doing the comparison. But is fkey a “float with integral value”? I dont think it is, and math.tointeger() doesn’t either (it returns nil).
The reality is Lua has three number ranges:
[a] Integers with a magnitude less than 2^52 (and can be represented exactly either as float or integer)
[b] Integers with magnitude greater than 2^52 but less than 2^63 (and can only be represented exactly as integers)
[c] Floats with magnitudes greater than 2^63
It’s the [b] range that is the problem here, and I don’t see any clear guidelines in the Lua docs to indicate how this range is handled when used as table keys.