title: acos(1) returns NAN in some conditions
body: <p>Here's my code:</p>
  
  <pre><code>&lt;?php
  
  $lat1 = 35.697959;
  $lat2 = 35.697959;
  $lon1 = 139.707085;
  $lon2 = 139.707085;
  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  var_dump($dist); // returns 1
  
  $dist = acos($dist); 
  var_dump($dist); // returns NAN
  </code></pre>
  
  <p>As you can see from the comments, <code>$dist</code> is equal to <code>1</code> after the calculation, but when I apply <code>acos()</code> it returns <code>NAN</code>. </p>
  
  <p>If I try to replicate it manually, it works just fine:</p>
  
  <pre><code>$x = 1;
  $x = acos($x);
  var_dump($x);  // returns 0 as expected
  </code></pre>
  
  <p>What's going on here and how can I fix it?</p>
  
  <p><a href="https://3v4l.org/2NFZr" rel="noreferrer">Here's the same code</a> in an online shell, so you can see that it actually returns those values.</p>