lua-users home
lua-l archive

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


On Fri, May 18, 2007 at 09:44:44AM -0300, Luiz Henrique de Figueiredo wrote:
> > If it is a floating point and you use it for integer calculations, can't 
> > you get unnecessary overhead? (nevermind the risk of precision loss)
> 
> No. If all calculations are done in Lua, they may even be faster. Moreover,
> with double precision floating point, you get a *wider* range of integer
> values. See

Don't forget that many systems (such as many gaming consoles) only have
32-bit hardware floats; 64-bit math on those is done in software.  IMO,
depending on 64-bit doubles is one of Lua's small warts.  I think it's
worth the wart in order to expose only one number type, but transparently
using ints where possible may have saved me some headaches, back before
I knew the implications of all this to design around it.  (Now I never
send anything like a bitmask into a lua_Number.)

-- 
Glenn Maynard