[erlang-questions] strictly less-than (Re: [erlang-questions] Ordered set and DETS)

Richard O'Keefe ok@REDACTED
Thu Sep 9 05:58:32 CEST 2010

On Sep 9, 2010, at 1:44 AM, David Mercer wrote:
> I wonder if the equality operator should even be applicable to floats.
> After all, float F1 really represents a number between F1 - epsilon and F2 +
> epsilon.

This is a popular misconception.  There is no fuzziness in the number that
a floating-point number represents.  The fuzziness is in the *operations*.
IEEE defines the floating point operations in terms of applying a
dynamically selected rounding algorithm to the infinitely precise result
of a mathematical operation on unambiguous inputs.

In particular, note that floating point add, subtract, multiply, and
compare are *exact* for integers expressed as floating point numbers,
provided the results are not too big.  Before 64-bit integers were
readily available, I've used IEEE doubles to get 53-bit integers.

In any case, we _can't_ drop term equality from Erlang, because it's an
essential part of pattern matching.  Arithmetic equality, maybe.

More information about the erlang-questions mailing list