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:

TIL what TIL means :-)


> 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

This is by design. As we are still playing with the exact behavior
of overflows in constants, we prefer not to fix it in the documentation
now. (This changed between releases of 5.3.)

-- Roberto