title: double precision in JAVA
body: <p>I have to round off my result to the nearest fo 0.05 ie(6.34 to 6.35 and 6.37 to 6.4)
      So I created myRound  function.
      When I wrote test to see the function, Its fails.</p>
  
  <pre><code>double rate=14.99;
  double  percentage=10;
  double roundedCost=(rate*percentage)/100; //round off to the nearest value. 
  double finalRate = rate+myRound(roundedCost,2);
  
  if(finalRate==16.49)
      System.out.println("Its proper");
  else
      System.out.println("Wrong");
  </code></pre>
  
  <p>The reason is precission value of double.
      <strong>How to correct the precision.</strong></p>
  
  <pre><code>public double myRound(double value,int roundRange)
  {
      double hundredMultiple=(float) Math.pow(10, roundRange);
      int rangeValue= (int) (value*hundredMultiple);
      int tempValue= rangeValue%10;
      if(tempValue&lt;5)
          tempValue=5-tempValue;
      else
          tempValue=10-tempValue;
      rangeValue=rangeValue+tempValue;
  
      return rangeValue/hundredMultiple;
  
  }
  </code></pre>