i know that if you want to check for equality for doubles you do:
return abs(a-b)<EPSILON
my question is: is that comparison to EPSILON also needed when i want to ask if a!=b?
my intuition says yes (because they might be equal), but from what i saw on the web it is not implemented with EPSILON
and one more question, what is the reason we use EPSILON when we want to check for equality in doubles or floats?
Probably the most common way to compare two doubles is the following (C++ code), becuase during the computation you can introduce errors due to cancellation, finite precision representation and other (for more details see What Every Computer Scientist Should Know About Floating-Point Arithmetic)
Then two doubles are different if they aren’t almost equals, so
a!=bbecome!almostEqual(a,b).