3 ms·
"In Lua < 5.3 a = 9223372036854775000 is not even valid code. Because only 32-bit integer values are supported." That's not true at all, Lua < 5.3 uses doubles
by Franciscouzo 10y ago
"In Lua < 5.3 a = 9223372036854775000 is not even valid code. Because only 32-bit integer values are supported."
That's not true at all, Lua < 5.3 uses doubles for all numbers, which on most computers is IEEE 754, they can represent integers perfectly up to 2^53
The value is not corrupted, depending on the rounding mode is which number you're going to get out of that (I get 9223372036854774784)
- copx 10y ago>That's not true at all, Lua < 5.3 uses doubles for all numbers I know that of course, but using doubles for integer math is only safe if you limit yourself to a certain integer range. >which on most computers is IEEE 754, they can represent integers perfectly up to 2^53 False. You get rounding errors after 10^14. >The value is not corrupted, depending on the rounding mode is which number you're going to get out of that (I get 9223372036854774784) The above being an example of such a rounding error. If I assign the value 9223372036854775000 to a variable I expect said variable to afterwards have the value 9223372036854775000 not 9223372036854774784. Your example is exactly what I meant with "corrupted" i.e. the value is changed by the conversion.