lua-users home
lua-l archive

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


On Sun, Jun 26, 2016 at 2:12 PM, Mooffie <mooffie@gmail.com> wrote:
On 6/26/16, Sean Conner <sean@conman.org> wrote:
> A double can "safely" store integers in the range:
>
>          -9007199254740992 ..     9007199254740992
>
> I say "safely" because past that range, integers start having "gaps"
> between [...]

I'm well aware of the fact that typically only integers less than 2^53
can be "safely" stored in Lua numbers (prior to Lua 5.2), and I'm fine
with this.

Just a side note: "safe storage" is not the same as "safe operations".
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