lua-users home
lua-l archive

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


Tony wrote:
On 11/14/2012 6:05 AM, Roberto Ierusalimschy wrote:
One of the main reasons that Lua uses double is to support full 32
bits. With a natural 32-bit integer, you could compile Lua with single
floats and then really reduce memory usage. But the introduction of
integers also solve a big reverse problem. Frequently, restricted
systems compile Lua with longs as its number type. And frequently,
there is the problem of how to manipulate floating point numbers on
those systems. Lua with 32-bit integers and single floats would use
much less memory, offering full 32 bits when needed, the speed of
integers for hardware without FP support, and floating point number
when necessary. -- Roberto

This would be especially useful for embedded use, since there are many
recent 32-bit MCUs with hardware single precision floating point (but
not double precision), and plenty of memory to run eLua or other minimal
Lua systems.

In fact, my pbLua for LEGO MINDSTORMS compiles Lua using 32 bit integers as the "normal" number type and introduces single precision float as a userdata type (with appropriate functions in the metatable)

I would really, really appreciate integers and floats as discrete built-in types, as long as we could specify single precision floats and 32 bit ints on the platforms where that resolution and dynamic range is good enough.

Ralph