lua-users home
lua-l archive

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

>From: Edgar Toernig <>

>I made a complete lua with integer arithmetic.  No floating point
>anywhere.  The standard lua has some problem when LUA_NUM_TYPE is
>long - it still uses floating point in a lot of places.

Not "a lot of places", but only in the lexer and in tonumber and tostring:

% grep LUA_NUMBER *.[ch]
lobject.c:double luaO_str2d (char *s) {  /* LUA_NUMBER */
lobject.h:** GREP LUA_NUMBER to change that
lundump.h:#define NUMBER_FMT    "%.16g"         /* LUA_NUMBER */
lvm.c:int luaV_tonumber (TObject *obj) {  /* LUA_NUMBER */
lvm.c:int luaV_tostring (TObject *obj) {  /* LUA_NUMBER */

(NUMBER_FMT in only used in luac.)

Of course, to completely avoid floating point, you have to change the API.
I've promised to write a LTN about this. Will do.