in reply to NaNs are true
Any attempt to use (a variable set to) NaN for anything, including numerical comparison with anything, including another (variable set to) NaN, or implicitly with either true or false in a conditional statement, should cause an exception.
It is the numerical equivalent of dereferencing a null pointer.
The only tests of NaN that (possibly) should not cause an exception, are for numerical equivalence with a predefined constant NaN, or (perhaps) stringified equivalence to a predefined constant NaN.
Even comparison of one variable set to NaN with another variable set to NaN should raise an exception because to do otherwise would be equivalent to allowing:
char *a = null, *b = null; if( ! strcmp( a, b ) ) { printf( "They are the same string\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: NaNs are true
by syphilis (Archbishop) on Feb 27, 2011 at 01:03 UTC | |
by BrowserUk (Patriarch) on Feb 27, 2011 at 01:32 UTC | |
by syphilis (Archbishop) on Feb 27, 2011 at 02:35 UTC |