lua-users home
lua-l archive

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


2015-04-23 9:59 GMT+02:00 Roberto Ierusalimschy <roberto@inf.puc-rio.br>:

> Morever, I guess (but may be wrong) that a better comparsion
> function (e.g., that compares the "true" mathematical values)
> would be expensive.

Such a comparison is in principle impossible.

The best one can do is to compare numbers to within a tolerance.
This need not be very expensive, e.g. take the larger magnitude
`x`, subtract say 45 (variable, or at least configurable) from its binary
exponent to get the tolerance, and the numbers are considered
"equal" if their difference is less than that.

But that amount of numerical sophistication would be out of place
in a language that does not even offer the hyperbolic functions
in a standard library.