title: -0 not equals 0
body: <p>I have a function that calculates a value, which is a float:</p>
  
  <pre><code>function crunch (float $a, float $b):float
  {
    //do stuff
    return $result;
  }
  
  function testSomething (float $a, float $b):bool
  {
    //if $result is -0 that returns false
    $result = crunch($a, $b);
    return $result === 0;
  }
  </code></pre>
  
  <p>Why is <strong>-0 not equal to 0</strong> and how can if safely check if that number is zero, assuming that <code>0</code> should be the same as <code>-0</code>? </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Since there was the question for more details. I have a class <code>Vec2</code> which has <code>x()</code> and <code>y()</code> getters, and a method called <code>cross</code>, which looks like that:</p>
  
  <pre><code>public function cross(Vec2 $vec2):float
  {
    return ($this-&gt;_x * $vec2-&gt;_y) - ($vec2-&gt;_x * $this-&gt;_y);
  }
  </code></pre>
  
  <p>Running this code:</p>
  
  <pre><code>$cross = $this-&gt;cross($d);
  </code></pre>
  
  <p>results in that debugger output </p>
  
  <p><a href="https://i.stack.imgur.com/Cj9dS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cj9dS.jpg" alt="enter image description here"></a></p>
  
  <p>and <code>$cross === 0</code> evaluates to <code>false</code>;</p>