Hacker News new | ask | show | jobs
by nycticorax 39 days ago
OK, I did not know about [saturation arithmetic](https://en.wikipedia.org/wiki/Saturation_arithmetic). Cool!

But I can't agree with the claim that "nan is almost always a mistake". Certainly if you're doing floating-point computation on large arrays, the last thing you want is e.g. for an error to be thrown in a elementwise division just because two corresponding elements both happen to be zero.

It's true that nan!=nan is one of the more 'controversial' parts of the standard, that possibly would have been decided the other way in a perfect world. But it was also a reasonable pragmatic decision at the time the standard was developed. See here: https://stackoverflow.com/a/1573715/1013442