lua-users home
lua-l archive

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



ps. There's one catch - storing 64 bit values as Lua constants needed a new VM operation to be defined. This version does read precompiled scripts from stock Lua, but not the other way round.

Lua authors:

Perhaps such an opcode could be in 5.2 anyhow, meaning integer constants would be stored separately of floating point ones. This would not require large changes in stock Lua, but would keep the unpatched, and patched versions completely compatible.

And this, too:

Add 'lua_isinteger()' to the C API. That function would return 1 for anything fitting into 'lua_Integer', and not having a fraction part (regardless if the intopt patch is actually used). This change would merely make the API consistent, since there already is lua_tointeger () and lua_pushinteger().


Asko Kauppi kirjoitti 24.8.2006 kello 10.49:


Apply the patch, and compile with -DLUA_NUMBER_MODE=22. You'll get a Lua executable behaving quite normally, but having also full int64 (signed) precision.

API is the same as regular Lua, so extension modules work as such.

-asko


<int-all-511.patch>
<int-all.txt>


Matt Campbell kirjoitti 24.8.2006 kello 3.47:

Hello Jason:

Because Lua's only numeric data type is a floating point number (a C
double), Lua doesn't support arbitrary 64-bit integers (long longs).
However, according to the book Programming in Lua, it does support
integers up to 100,000,000,000,000. So your best bet is just to push the
long long using lua_pushnumber and let the compiler convert it to a
double. Does anyone else have additional information on this?

--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"