[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Numeric key collision related bug in Lua 5.3
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 24 Apr 2015 11:54:32 +0200
2015-04-23 9:59 GMT+02:00 Roberto Ierusalimschy <email@example.com>:
> 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.