redis-lua
redis-lua copied to clipboard
Large integers support
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.
(related: https://github.com/catwell/fakeredis/commit/a076588b87f24b1f5982c01e3265074a81b95db0#diff-cb226e1732729d7a5e8f0508ee7de92eR127)