Quantcast
Channel: Daz Script Developer Discussion - Daz 3D Forums
Viewing all articles
Browse latest Browse all 1036

How to test for NaN? [SOLVED]

$
0
0

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
})();

 


Viewing all articles
Browse latest Browse all 1036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>