> Sometimes operations on such "integers" give wrong results:
>
> > a = 2^53-1
> > =("%.f"):format(a)
> 9007199254740991
> > =(-a)%(a-1)
> -1
> > =math.floor((-a)/(a-1))
> -1
On my machine I've got correct results.
That output was produced by Lua 5.2.0 on Windows XP.
The same test under Lua 5.3.3 on Linux Mint 17 gives wrong result only for math.floor: Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio ; a = 2^53-1 ; =("%.f"):format(a) 9007199254740991 ; =(-a)%(a-1) 9.007199254741e+15 ; =math.floor((-a)/(a-1)) -1
Under some other combinations of "Lua5.x + OS y" the results are indeed correct.
Yes, precision errors are possible in integer calculations when working with "integers" inside floats.
I just want to say that it may be quite unexpected.