Yes. It's also how NaNs are supposed to work according to IEEE-754.
The only reason why it can be strange in javascript is that it's pretty common to encounter nans in JS as the language tries very hard not to throw errors and likes nans a lot (so `parseInt('foo')` returns NaN instead of `null` or an error), whereas it's very rare in other languages. Pretty much all languages have nans, and all nans behave this way. Here it is in Python:
>>> float('nan')
nan
>>> float('nan') == float('nan')
False
>>> float('nan') != float('nan')
True
>>> a = float('nan')
>>> a == a
False
>>> import decimal
>>> decimal.Decimal('NaN')
Decimal('NaN')
>>> decimal.Decimal('NaN') == decimal.Decimal('NaN')
False
>>> a = decimal.Decimal('NaN')
>>> a == a
False
edit: now that I think about it, there is a difference: in SQL, all operations involving `NULL` (including comparisons) return `NULL`, so `NULL = NULL` => `NULL` and `NULL != NULL` => `NULL`.
Yes. It's also how NaNs are supposed to work according to IEEE-754.
The only reason why it can be strange in javascript is that it's pretty common to encounter nans in JS as the language tries very hard not to throw errors and likes nans a lot (so `parseInt('foo')` returns NaN instead of `null` or an error), whereas it's very rare in other languages. Pretty much all languages have nans, and all nans behave this way. Here it is in Python:
edit: now that I think about it, there is a difference: in SQL, all operations involving `NULL` (including comparisons) return `NULL`, so `NULL = NULL` => `NULL` and `NULL != NULL` => `NULL`.