I guess would argue there's a thin, but important, line between a superstition 
and a heuristic. Universally avoiding exact equality tests for floating point 
values seems like the simplest heuristic that would generally lead one to 
correct conclusions, whereas using exact equality tests while merely hoping 
they will work out seems like a very risky heuristic.

 -- John

On Nov 20, 2014, at 12:08 AM, Steven G. Johnson <[email protected]> wrote:

> 
> 
> On Wednesday, November 19, 2014 6:04:54 PM UTC-5, John Myles White wrote:
> This does not happen on my machine. Can you give more details about your 
> setup? 
> 
> To be clear, 1/1 is a floating point number, which means that the whole idea 
> of doing == is dangerous. A safer comparison is the distance between the 
> values. I get the following:
> 
> Nothing dangerous in this case.  1/1 will be exactly 1.0 in correctly-rounded 
> floating point (i.e. IEEE), and as Stefan says, x * 1.0 == x for all non-NaN 
> floating-point values due to correct rounding.   Let's not elevate 
> floating-point roundoff to the level of superstition.
> 
> (I can't reproduce the behavior reported by the original poster either.)

Reply via email to