lua-users home
lua-l archive

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

>Sounds like normal floating point inaccuracies when trying the entire
>fractional part of a number.  This happens on every platform.

Really, even for integers? I'd expect this to happen only for numbers that
have a fractional part which is not an exact binary fraction, but not for
integers and never for small integers such as 65.

Also, it depends whether the number is read or computed. For instance,
print(sin(30)) will almost never print 0.5 but rather 0.4999999999999999,
because it's computed. In this case, changing the number of decimals printed
does help. In Lua, "print" always outputs enough digits so that the number
may be reproduced from the textual form (16 for doubles).