lua-users home
lua-l archive

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



Is there a "built-in" C number type (even if it isn't proper ANSI C, and is some kind of gcc extension weirdness) which is big enough, or which is arranged in such a way, that I can easily rebuila Lua with this as my intrinsic representation of number, can still enjoy the fruits of floating point, yet still have more than 64 bits of integer accuracy under Windows and Linux under both 32-bit and 64-bit OSes.

Actually, I think I mean 65 bits, as I want to be able to do addition and subtraction of any two 64-bit integers, signed _or_ unsigned, and get the correct result. Actually, I probably mean 66 bits :) What do I mean? I want to be able to add and subtract correctly _all_pairs of numbers which I might get out of 8 bytes, regardless of whether I have an S64 and a U64, or a U64 and a U64, or an S64 and an S64.

Is this easy to do with a (non-standard) build of (standard) Lua and libraries? I don't care about the numbers mapping directly into Intel registers. Performance is only very mildly important.

I'm not very good at floating point, but IIRC the IEEE "long double" (80-bit "doubles") can only represent integers exactly with absolute values up to 2^63.

A truly general-purpose "bigint" system is not necessary, but I don't mind doing it that way if I can still use "regular" Lua code and libraries.

I have explained this terribly badly, but am still hoping someone will [a] understand and [b] have a "change these 5 lines in luaconf.h and rebuild" answer for me.