integer precision

Hi, does exist a way in Codea to handle large ‘integer’ values with right precision?

for example, the following code will print 0 instead of 6

i1 = 2147483688
i2 = 2147483682

and that’s because both are considered as 2.14748e9

Codea’s Lua uses floats (32 bit) for numbers, that gives you only 23 bits and a sign bit for the integer range, i.e. 8388607 is the biggest possible exact integer.

There’s a put Lua BigNum library here:

I haven’t looked into it, but maybe it’s what you need.

Yes, thanks @Codeslinger, I’ ve also read another post that refers to a similar problem:

My real need is to correctly parse a file written by another app where some integers are used in a mixed way: 3 most significant bit as flags, the remaining as int value. I’ve a solution for this specific problem, but it’s not something I really like :frowning:

Anyway is a real pity having numbers as single float precision (even if probably having them as double float precision would slow down codea performance, or am I wrong?)