lua-users home
lua-l archive

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


> I'm not quite sure what your are asking.. But if you replace
> all "double" with "float" (and the formatting string %g) you
> application will use float a numerical base...
>> Perhaps the best way to do this is to define the macro LUA_NUM_TYPE
(i.e. -DLUA_NUM_TYPE=long) as described in lua/config.
>>In my Lua version, I added some functions to do
and/or/xor/shift/rotation with 32 bit Interger, but internally Lua
still use only doubles which are changed to unsigned long when it is
needed.

I think this is potentially the best solution.

Martin:
>> You would have to change the parser - and make it bigger, that it
seperates float from integer values and also would need another VM. I
think, that you just will get problems with very big numbers. How is this
done in other languages (e.g. Perl/Python)?

I dont really fancy modifying the parser when there is a simpler solution ie.
use doubles and cast. Python handles floats/doubles and ints/longs and and you
can cast between them. eg. int(float_val) and float(int_val). I was just
wondering whether someone had a novel solution for adding float/int support to
Lua when it only handles one number type. One of the main reasons for this is so
it can handle 32 bit colour values but there are several ways I can get around
this using a tagged type or wrap a C function to set colour from a Lua tuple.

N