lua-users home
lua-l archive

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


The system that this version of Lua is intended for doesn't support floating point math at all, but I need to support enough precision to interface with OpenGL, so I think it's easier to just limit the basic Lua type to fixed point..  I hope there aren't too many more problems to run into, as you suggested :P.

Thanks

On 28/04/2008, Ralph Hempel <rhempel@hempeldesigngroup.com> wrote:
Gregory Lamoureux wrote:
Hello,

I've modified Lua to work using only fixed point 32 bit integers.  ie, any number entered in a script or interpreter is automatically intercepted and converted to fixed point values (1e10 -> 655360, 0x0002->131072, etc..).  Most of the changes were made to luaconf.h, but there were two other issues I had to fix:

There are probably a few more that you may not have run into
yet either :-)

I've been down this road too, using standard 32bit long as the
fundamental number type and then trying to wedge single precision
floats in as a special case.

After about a year of messing around, I came to the conclusion that
the times that I need floats are generally well known, and the user
has to think about when to use them as well, so why not just make
them a special userdata type with a metatable to deal with the
common arithmetic operators.

Would this apply to your situation as well, or is the use of
fixed point math so pervasive in your application?

Cheers, Ralph