When -11.5 plus 11.5 equals float(2.8421709430404E-14)
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3726721/php-math-precision">PHP Math Precision</a><br>
  <a href="http://stackoverflow.com/questions/3819508/best-practice-for-working-with-currency-values-in-php">Best practice for working with currency values in PHP?</a>  </p>
</blockquote>



<p>I really hope someone can help. I've been hitting my head against a brick wall on this one.</p>

<p>Here's the situation:
I have a checkout which calculates the subtotal after discount to be -£11.50. There is then  £11.50 delivery cost to add which IMHO should equal £0.</p>

<p>However when the calculation is run it returns a float 2.8421709430404E-14</p>

<p>In my debug efforts I have done this:</p>

<pre><code>var_dump(
    $build['total'], // float(-11.5)
    $build['delivery'], // float(11.5)
    (($build['total'])+($build['delivery'])) // float(2.8421709430404E-14)
);
</code></pre>

<p>However when I do a static calculation:</p>

<pre><code>var_dump((-11.5 + 11.5)); // float(0)
</code></pre>

<p>Any ideas?</p>
