lua-users home
lua-l archive

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


Roberto Ierusalimschy wrote:

Besides, the idiosyncrasies of IEEE floating point are well studied (one
can say they were even well designed) and documented. To add a new set
of idiosyncrasies into Lua arithmetic opens a whole new world...

I have to agree here - without diminishing the usefulness of the LNUM
patch for some applications. Right now, the Lua math works fine for
most applications.

For one of my applications, which is a port of Lua to LEGO MINDSTORMS
NXT running on an ARM7 core, I decided that 32 bit int was a good choice
for the fundamantal numeric type.

I was able to add single precision float math using a library of C
code, but kept using 32 bit integers as the basic number system.

The programmer has to make an explicit conversion of a number to
a float, and is therefore responsible for using the resulting
number correctly :-)

As Roberto points out, the IEEE floats have some neat properties, and
the one that always amazes me is that integer magintude comparisons
such as greater or less than  work on floats...

Cheers, Ralph