NaN is part of IEEE754 but of course it's not a 'real' number (integer numbers don't have NaNs)
Edit: you can consider NaN (and to a degree both infinities) as an exception, once it occurs - it has to be propagated. Any operation involving NaN should be returning NaN, any operation comparing NaN to anything has to return 'false'. That includes "if (NaN == NaN)". boolean isNaN(double d) is effectively "return d != d;"
That's not a given, though. IEEE 754-2008 defined min and max as returning the non-NaN parameter. They have been removed in IEEE 754-2019 though.
You can say that a call to max should return NaN if any argument is NaN, but you can't say the same about sorting. (For one thing... sorting an array doesn't return a scalar value.) Sorting is done with comparisons, and what happens if a NaN gets into the list of values will depend on which specific comparisons happen to be done.
By definition, something that is not a number (real, integer, etc.) cannot be compared to something that is a number.
>>> max(float('nan'), 0)
nan
>>> max(0, float('nan'))
0
Numpy works though >>> np.maximum(float('nan'), 0)
nan
>>> np.maximum(0, float('nan'))
nan
Edit: Fixed numpy example.Source: http://tom7.org/nand/nand.pdf
Edit: As of 2019, the formerly required minNum, maxNum, minNumMag, and maxNumMag in IEEE 754-2008 are now deleted due to their non-associativity. [https://en.wikipedia.org/wiki/IEEE_754#2019]
np.clip(ndarray, lower_bound, upper_bound)
And handles NaNs correctly.Recording the lack of a value is what null is for.