How to test for NaN? [SOLVED]
Praxis
Posts: 254
In DS v4.10.0.123, a test for Number.NaN always seems to return false. Am I missing something?:
// Script to test Number.NaN// Define an anonymous function;// serves as our main loop,// limits the scope of variables(function(){ print( ' ' ); print( App.longVersionString ); // 4.10.0.123 print( ' ' ); var X; X = 1 / 0; print( 'X=1/0', X ); // Infinity print( X == Number.NaN ); // false print( X == Number.POSITIVE_INFINITY ); // true <---OK print( X == Number.MAX_VALUE ); // false print( X == Number.NEGATIVE_INFINITY ); // false print( X == Number.MIN_VALUE ); // false print( ' ' ); X = Math.sqrt( -1 ); print( 'X=sqrt(-1)', X ); // NaN print( X == Number.NaN ); // false <---!!! Should be true print( X == Number.POSITIVE_INFINITY ); // false print( X == Number.MAX_VALUE ); // false print( X == Number.NEGATIVE_INFINITY ); // false print( X == Number.MIN_VALUE ); // false print( ' ' ); X = Number.NaN; print( 'X=NaN', X ); // NaN print( X == Number.NaN ); // false <---!!! Should be true print( X == Number.POSITIVE_INFINITY ); // false print( X == Number.MAX_VALUE ); // false print( X == Number.NEGATIVE_INFINITY ); // false print( X == Number.MIN_VALUE ); // false print( ' ' );// Finalize the function and invoke})();
Post edited by Praxis on
Comments
Global::isNaN()
Thank you for that!