lua-users home
lua-l archive

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


Lua numbers are doubles by default. Doubles only have 52 bits for the significant.

If you want to avoid external dependencies, you can write your own bignum library in lua to deal with numbers 52+52=104 bits wide. Values would be (a * 2^52 + b) where a is the top 52 bits and b the bottom ones, so it's just a question of math to derive the arithmetic operations ;)

On 07/10/2010 20:55, Cosmin Apreutesei wrote:
Hi,

This post may sound stupid, but I haven't found/been able to produce a
decent int64 (read as 2 ints or 8 bytes or whatever) to string
conversion function made in Lua without bitops or integer
multiplication past 52bit. Any hints/links? Just want to provide it as
a fallback to installing a bignum library in fbclient.

Thanks,
Cosmin.