title: Java sum of all double does not return expected result
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4937402/moving-decimal-places-over-in-a-double">Moving decimal places over in a double</a>  </p>
  </blockquote>
  
  
  
  <p>Why is the following sum of numbers not equal to <code>0.4622</code>? but <code>0.46219999999999994</code></p>
  
  <pre><code>Double total = new Double(0.08) + new Double(0.0491) + new Double(0.3218) + 
           new Double(0.0113) + new Double(0.0); // = 0.46219999999999994
  </code></pre>
  
  <p>I have an application that checks the users input.</p>
  
  <p>The user inputs 5 decimal numbers and a total number. The application checks if the sum of all 5 numbers capped at 4 decimals behind the komma is equal to the total number. </p>
  
  <p>Capping it gives me <code>0.4621</code> which is not equal to <code>0.4622</code>. I can't use DecimalFormat because it rounds it up. And if i explicitly say, round down then it will fail for this situation.</p>
  
  <p>Any suggestion for how I can solve this?</p>