lua-users home
lua-l archive

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

"Sebby" wrote:

> that's one of the things i would like to see in
> the future, an easy way of switching from double
> to floats.

You kids today with your floating point!  Back in my day, all we had were
integers, and we were happy to have them!  Get off my lawn!

One of the things I would really like to see in Lua is the ability to make
numbers purely integer.  Right now, you can tell the compiler
-DLUA_NUM_TYPE=long and that would do most of the job.  But it doesn't go
far enough.  In Lua 4.0 alpha, there are functions like expten and
luaO_str2d in lobject.c that define floating point constants and store them
in doubles.  And I found a sprintf() with a format specifier of "%.16g" in
lvm.c.  These trigger the linker to bring in floating point code.  The goal
would be that one could compile Lua in integer-only mode and not have the
linker even be tempted once to link any floating point support.

Maybe Lua 4.0 beta addresses this-- maybe not.  I haven't looked at it yet.
But I do want to state that I'll bet there are a number of Lua users who
don't use floating point at all in their applications, and would enjoy not
having the implicit dependencies on floating point there.  And if for no
other reason, having a mode to compile Lua in integer-only mode would make
the already screaming VM even more insanely fast.

I would appreciate anyone who has done a floatingpointectomy to Lua 4.0
alpha to point out if there are any subtle areas to look out for.  The
sprintf() in lvm.c is pretty obvious, but I'm guessing there might be
others lurking.