[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Overflow of hex vs decimal integer literals
- From: Daurnimator <quae@...>
- Date: Thu, 23 Feb 2017 11:45:20 +1100
TIL that hex literals don't overflow into floats:
Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio
> 0x7fffffffffffffff
9223372036854775807
> 0x7ffffffffffffffff
-1
> 0x7fffffffffffffffff
-1
> 0x2222222222222222
2459565876494606882
> math.type(0x2222222222222222)
integer
> 0x22222222222222222
2459565876494606882
> math.type(0x22222222222222222)
integer
vs decimals:
> 9223372036854775807
9223372036854775807
> math.type(9223372036854775807)
integer
> 9223372036854775808
9.2233720368548e+18
> math.type(9223372036854775808)
float