sum of numbers returns odd low decimals?
<p>When summing a group of numbers sometimes I end up with some low decimals? Why can it happen when the numbers are parsed as strings? I know there is some %"&amp;! about floats</p>

<pre><code>function parse(){
    foreach($_SESSION['import_csv_posts']['result']['csv'] as $key =&gt; $post){
        $amount = $this-&gt;parse_amount($post[$this-&gt;param['amount']]);
        if($this-&gt;param['vat_amount']){
            $amount += $this-&gt;parse_amount($post[$this-&gt;param['vat_amount']]);
        }

        $this-&gt;balance += $amount;
        echo "$amount\n";
    }

    echo "\nbalance = ".$this-&gt;balance;
}

function parse_amount($amount){
    $amount = strval($amount);
    if(strstr($amount, '.') &amp;&amp; strstr($amount, ',')){
        preg_match('/^\-?\d+([\.,]{1})/', $amount, $match);
        $amount = str_replace($match[1], '', $amount);
    }

    return str_replace(',', '.', $amount);
}
</code></pre>

<p>result</p>

<pre><code>-87329.00
-257700.00
-11400.00
-9120.00
-47485.00
-15504.00
122800.00
1836.00
1254.00
200.00
360.00
31680.00
361.60
1979.20
1144.00
7520.00
6249.49
balance = -399.00000000003
</code></pre>
