title: how to fix double precision issue in java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5257166/java-floats-and-doubles-how-to-avoid-that-0-0-0-1-0-1-0-9000001">Java floats and doubles, how to avoid that 0.0 + 0.1 + &hellip; + 0.1 == 0.9000001?</a>  </p>
  </blockquote>
  
  
  
  <p>How can I overcome the precision issue with double multiplication in java android??Please note that I am converting a string value into double value.</p>
  
  <p>eg: when I multiply two double value: </p>
  
  <pre><code>double d1 = Double.valueOf("0.3").doubleValue() * Double.valueOf("3").doubleValue();
  System.out.println("Result of multiplication : "+d1);
  </code></pre>
  
  <p>I am getting the following result : 0.8999999999999999</p>
  
  <p>Some of the results that i am getting are.</p>
  
  <blockquote>
    <p>0.6*3=1.7999999999999998; <br />
    0.2*0.2=0.04000000000000001; <br />
    etc.</p>
  </blockquote>
  
  <p>Instead of the above results I would like to get the following results. </p>
  
  <blockquote>
    <p>0.3*3=0.9; <br />
    0.6*3=1.8; <br />
    0.2*0.2=0.04;</p>
  </blockquote>
  
  <p>Please remember that I am not trying to round it to the nearest integer.</p>