PHP How to round up correctly?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3726721/php-math-precision">PHP Math Precision</a>  </p>
</blockquote>



<p>This is a very simple rounding of a number, but for some reason it chooses to ignore the last digit rather than rounding up correctly.</p>

<pre><code>$number = 4886.94 * 1.25;
$number = round($number,2);
echo "Test: ".$number."&lt;br /&gt;";
</code></pre>

<p>The total number is 6108.675 but it rounds down to .67 rather than .68.</p>

<p>But if I write it out directly likes this:</p>

<pre><code>$number = 6108.675;
$number = round($number,2);
echo "Test: ".$number."&lt;br /&gt;";
</code></pre>

<p>It now rounds up to .68 correctly.</p>

<p>What am I missing?</p>

<p><strong>Update:</strong></p>

<p>This is undoubtedly a "hack", but alas...</p>

<pre><code>$number = substr($number,0,strpos($number,".")+4);   
$number = round($number,2);
</code></pre>

<p>It gives me the 3 digits that I can round up correctly.</p>
