PHP - Why does my computation produce a different result when I assign it to a variable?
<p>I want to round a number to a specific number of significant digits - basically I want the following function:</p>

<pre><code>round(12345.67, 2) -&gt; 12000
round(8888, 3) -&gt; 8890
</code></pre>

<p>I have the following, but there's a strange problem.</p>

<pre><code>function round_to_sf($number, $sf) 
{
 $mostsigplace = floor(log10(abs($number)))+1;
 $num = $number / pow(10, ($mostsigplace-$sf));

 echo ($number / pow(10, ($mostsigplace-$sf))).' '.$num.'&lt;BR&gt;';
}

round_to_sf(41918.522, 1);
</code></pre>

<p>Produces the following output:</p>

<pre><code>4.1918522 -0
</code></pre>

<p>How can the result of a computation be different when it's assigned to a variable?</p>
