nrk/redis-lua

Large integers support

catwell opened this issue · 1 comments

You use tostring to convert numbers to the Redis protocol format. This does not work correctly with integers above 10^14:

> =tostring(10^14-1)
99999999999999
> =tostring(10^14)
1e+14

It is possible to support numbers up to about 2^53, i.e. about 9*10^15, by using string.format instead:

> =string.format("%d",10^14)
100000000000000

Everything above 2^53-1 or below 2^53+1 is dangerous anyway, because you start seeing this:

> x = 2^53
> =(x == x+1)
true

Not sure how the client should handle this.