Skip to content

Comment on Demystifying NaN for the Working Programmerparent

Comments

That's easy: y > 0 is False, not NaN.

You may not think this is wise, but this is very much how comparisons with NaN are defined.

And I think this is better than exception raising. Again, I think it would be _really_ weird for simple value comparisons to throw.

Again, I think it would be _really_ weird for simple value comparisons to throw.

But ... why?

You may say that NaN > 0 is defined as False, but we know that's not how programmers think, most of the time.

In code like if(y > 0) steer_car_to_left() I don't want the compiler or the IEEE standard to make any choices for me! Let it throw, so emergency systems can kick in.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.