News for hackers. Stuff that matters.
Re:In Erlang/OTP 27, +0.0 will no longer be exactly equal to... by Someone on Tuesday May 09, 2023 @07:27PM (#35881690)
That’s bad enough, but it is not the problem with defining an “epsilon”, it’s a problem.

Another one is that you would lose transitivity on equality. With a 1% epsilon, you would have

   1.000 == 1.005
   1.005 == 1.010
   1.010 == 1.015
 
but

   1.000 != 1.015
You also would have to be careful on how to define that 1% error range. the naive "x is equal to all numbers between 0.99x and 1.01x" would mean 1.0 would be considered equal to 0.99, but 0.99 would not be considered equal to 1.0 (1.01 times 0.99 is less than 1.0)

You also lose that, if a == b and c == d it follows that a + c == b + d.

The behavior around zero also will go against intuition. If you consider 0.99 and 1.0 to be equal, do you really want 1.0E-100 and -1.0E-100 be different?

There are no comments on this comment yet.