title: php float calculation 2 decimal point
body: <p>Got a math calculation problem.</p>
  
  <pre><code>$a = 34.56
  
  $b = 34.55
  </code></pre>
  
  <p><code>$a</code> do some calculation to get this figure</p>
  
  <p><code>$b</code> is doing rounding to the nearest 0.05 to get this figure</p>
  
  <p>what happens is</p>
  
  <pre><code>$c = $b - $a
  </code></pre>
  
  <p>supposedly it be -0.01, but I echo out the <code>$c</code>, which shows -0.00988888888888</p>
  
  <p>I try to use <code>number_format($c, 2)</code>, but the output is 0.00,</p>
  
  <p>how can I make sure <code>$a</code> and <code>$b</code> is exactly 2 decimals, no hidden number at the back.</p>
  
  <p>in my php knowledge, <code>number_format</code> is only able to format the display, but the value is not really 2 decimal,</p>
  
  <p>I hope I can get help from here. This really frustrated me.</p>