lua-users home
lua-l archive

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


> Given that this subject comes up every couple of months, and that there are some subtleties to it, that this warrants a new function in the math library to do it the right way?

I don't think so. Floating-point arithmetic is not simple. I think it'd be
a disservice to try to hide its complexities in a official function that
may give the impression that it solves the problem reliably, when it can't.

On the other hand, there is nothing instrinsically wrong with floating-point
equality. The only catches come from numbers that should be equal but are
computed in two different ways and from naive expectations such as
300 * 0.7 == 21, due to a misunderstanding that floating-point representation
is a binary one, not a decimal one.