lua-users home
lua-l archive

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


> If I'm reading it right, it makes integer representation mostly
> transparent; MAXINT+1 overflows and is represented as floating point.

This is not defined yet, although I do not see any usefulness in this
behavior except that it is compatible with current Lua.

We expect that the most common configurarions will be with double+64bit
integers or float+32bit integers. In both cases, changing MAXINT+1 to
float throws away the "+1". (OK, that happens with MAXINT+1+1, but never
mind...) This is hardly useful. If you are doing computations with
integers, you expect full precision, not an "aproximation".


> The only odd behavior is with (integer,integer) arithmetic when there
> are precise integers outside the range of precise floating point
> numbers. This happens with 64-bit ints and IEEE doubles, or 32-bit
> ints and IEEE single precision. (Or with 16-bit int, it happens almost
> immediately.) AFAICT the semantic damage is limited to calculations
> sensitive to IEEE 754 behavior: don't do gravitation simulations in Lua
> with this patch on. But numerical analysis is not my strength.

All computations done with floats will follow the usual rules for IEEE
754.  You have full control over how your computations are done (int
or float). But more often than not you do not need/want to exert this
control.

-- Roberto