title: Correctly handing NAN in PHP versions
body: <p>Can anyone explain why <code>NAN</code> and a variable equal to <code>NAN</code> behave differently depending on the version of PHP?</p>
  
  <p>Consider the following code:</p>
  
  <pre><code>$nan = NAN;
  print "PHP Version: " . phpversion(). "\n" .
    '0 &lt;  NAN ? ' . ( 0 &lt; NAN   ? 'TRUE' : 'FALSE' ) . "\n" .
    '0 &gt;  NAN ? ' . ( 0 &gt; NAN   ? 'TRUE' : 'FALSE' ) . "\n" . 
    '0 == NAN ? ' . ( 0 == NAN  ? 'TRUE' : 'FALSE' ) . "\n" . 
    '0 &lt;  $nan ? ' . ( 0 &lt; $nan  ? 'TRUE' : 'FALSE' ) . "\n" .
    '0 &gt;  $nan ? ' . ( 0 &gt; $nan  ? 'TRUE' : 'FALSE' ) . "\n" .
    '0 == $nan ? ' . ( 0 == $nan ? 'TRUE' : 'FALSE' ) . "\n" .
    'is_nan(NAN) ' . ( is_nan(NAN)  ? 'TRUE' : 'FALSE' ) . "\n" .
    'is_nan($nan) ' . ( is_nan($nan) ? 'TRUE' : 'FALSE' ) . "\n" .
    'gettype(NAN) is '  . gettype(NAN)  . "\n" .
    'gettype($nan) is ' . gettype($nan) . "\n";
  </code></pre>
  
  <p>Now, if I run this code against many versions of PHP (using MAMP) the following are results:</p>
  
  <pre><code>PHP Version: 5.3.5
  0 &lt;  NAN ? TRUE
  0 &gt;  NAN ? TRUE
  0 == NAN ? FALSE
  0 &lt;  $nan ? TRUE
  0 &gt;  $nan ? TRUE
  0 == $nan ? FALSE
  is_nan(NAN) TRUE
  is_nan($nan) TRUE
  gettype(NAN) is double
  gettype($nan) is double
  
  PHP Version: 5.6.30 (and 5.5.30, 5.4.45)
  0 &lt;  NAN ? FALSE
  0 &gt;  NAN ? FALSE
  0 == NAN ? FALSE
  0 &lt;  $nan ? FALSE
  0 &gt;  $nan ? FALSE
  0 == $nan ? FALSE
  is_nan(NAN) TRUE
  is_nan($nan) TRUE
  gettype(NAN) is double
  gettype($nan) is double
  
  PHP Version: 7.1.1 (and 7.0.15)
  0 &lt;  NAN ? TRUE
  0 &gt;  NAN ? TRUE
  0 == NAN ? FALSE
  0 &lt;  $nan ? FALSE
  0 &gt;  $nan ? FALSE
  0 == $nan ? FALSE
  is_nan(NAN) TRUE
  is_nan($nan) TRUE
  gettype(NAN) is double
  gettype($nan) is double
  </code></pre>
  
  <p>Can a function in PHP rely on a comparison to NAN or should NAN only be used with <code>is_nan()</code>?</p>