title: Php error sum (exponential)
body: <p>I have an array of values, e.g.</p>
  
  <pre><code>+10.00
  -5.00
  +0.75
  -5.75
  </code></pre>
  
  <p>Their sum must be zero, instead I read an  <code>-3,5527136788005E-15</code> at screen.</p>
  
  <p>This is my code:</p>
  
  <pre><code>$currSum = 0;
  
  
  foreach ($transactions as $key=&gt;$value)
  {
      $currSum += (float)$value['amountFinal'];
      echo '&lt;p&gt;sum is: '.$currSum.'&lt;/p&gt;';
  }
  </code></pre>
  
  <p>I did try with and without the <code>(float)</code> cast.</p>
  
  <p>Data being from MySQL.</p>
  
  <p>This is the <code>$transactions</code> array (example)</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [idTransactions] =&gt; 42809
              [amountFinal] =&gt; 1.95
              [idAccount] =&gt; 143
              [dateTransaction] =&gt; 2014-04-11 16:29:37
  
          )
  
      [1] =&gt; Array
          (
              [idTransactions] =&gt; 43455
              [amountFinal] =&gt; 1.50
              [idAccount] =&gt; 143
              [dateTransaction] =&gt; 2014-04-17 16:06:53
  
          )
  )
  </code></pre>
  
  <p>Edit: I need to calculate sum step by step because, if sum is zero, I need to:</p>
  
  <p>1 - store [idTransactions] in another array
  2 - delete idTranscation from MySQL.</p>
  
  <p>(no problem for 1 and 2, but if $curSum != 0 I cannot achieve my goal)</p>