3 ms·
This looks very much like NULLs in the SQL world. A null (and NaN) is like an unknown. One can't compare unknowns because they are exactly that, unknown. Let
by adamzochowski 14y ago
This looks very much like NULLs in the SQL world.
A null (and NaN) is like an unknown. One can't compare unknowns because they are exactly that, unknown.
Let's construct a language that on division on zero returns unknowns.
a = 5 / 0;
b = 10 / 0;
Now, both a and b are set to unknown state. If one were to compare a to b, should the expectation be that they hold same value?
I wish all languages would have nullability like SQL does. Where a great care has to be given to deal with nullable data, lest nulls nullify everything.
- malkia 14y agoIn some languages, a, b would be +Infinity. On top of my head I can't remember whether +Infity != +Infinity (have to write a test and see). For NaN's definitely.
- tikhonj 14y agoOne of those languages is JavaScript, so--assuming your browser supports JavaScript--you do have somewhere to test it :P. The answer is that 5 / 0 is Infinity and (5 / 0) == (5 / 0), so it's all good :). Now, 0 / 0 is NaN and (0 / 0) != (0 / 0).