title: php sprintf displaying wrong number
body: <p>I'm having a weird problem where PHP's <code>sprintf</code> seems to be changing some numbers. This doesn't happen all the time, just occasionally.</p>
  
  <p>The following code:</p>
  
  <pre class="lang-php prettyprint-override"><code>echo sprintf('%04d',$product['priceUSD']*100)."(".($product['priceUSD']*100).")";
  </code></pre>
  
  <p>generates the following output for a $19.99 product: <code>1998(1999)</code></p>
  
  <p>I can work around this, but I'd love to know why it is doing it, and if there's any method to the apparent madness.</p>
  
  <p>Update:
  It looks like it's happening when converting from float to int.  The following gives the same output:</p>
  
  <pre class="lang-php prettyprint-override"><code>echo (int)($product['priceUSD']*100)."(".($product['priceUSD']*100).")";
  </code></pre>