2 ms·
Isn't "if(x != x)" the canonical way to test whether x is NaN? That seems like quite a big thing to break.
by josephcsible 4y ago
Isn't "if(x != x)" the canonical way to test whether x is NaN? That seems like quite a big thing to break.
- jeroenhd 4y agoMost languages have some kind of isNaN(value) method in my experience. Even C and C++ have an isnan method (C since ±1999, but other platforms had the macro before: https://repo.or.cz/w/glibc.git/blob/HEAD:/sysdeps/ieee754/dbl-64/s_isnan.c https://repo.or.cz/w/glibc.git/blob/HEAD:/sysdeps/ieee754/db...) People do probably rely on NaN ≠ NaN but I think that's more of a side effect of compatibility than anything else.
- morelisp 4y agoGo's implementation of math.IsNaN is return f != f