S
Steven D'Aprano
That doesn't follow. The problem is not that x < nan returns False
because that is correct since x isn't smaller than nan.
Comparisons between things which are not comparable risk being terribly
misleading, and depend very much on how you define "less than" and
"greater than". If you insist that everything must have a boolean yes/no
answer ("Does the colour red have a better chance of becoming President
than a kick to the head?") then False is not an entirely unreasonable
result to return.
But if you consider that having "x is not smaller than y" be equivalent
to "x is greater than or equal to y" is more important than forcing a
boolean answer in the first place, then you need something to signal
Undefined, and an exception is the right solution unless you have multi-
valued logic system (True, False, Maybe, Undefined, ...)
SANE (Standard Apple Numerics Environment) explicitly states that it
signals an exception when doing ordered comparisons against NaNs because
to return False would be misleading. Apple went on to use the same rule
in their PowerPC Numerics. That's straight out of the Zen: Practicality
Beats Purity.