lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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