title: Double minus int giving unexpected results
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1661273/floating-point-arithmetic-not-producing-exact-results-in-java">Floating point arithmetic not producing exact results in Java</a><br>
    <a href="https://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples">Floating point inaccuracy examples</a>  </p>
  </blockquote>
  
  
  
  <p>In Java, given the following code:</p>
  
  <pre><code>    double amount = scan.nextDouble();
  
      tenBills = (int)amount / (int)10;
      amount = amount - (tenBills * 10);
  
      fiveBills = (int)amount / (int)5;
      amount = amount - (fiveBills * 5);
  </code></pre>
  
  <p>After the first calculation, given an input of say 16 amount will equal 6.66 . But after the second calculation amount will be 1.6600000000000001 . I don't understand why subtracting an int from a double would cause such a result.</p>