title: Addition in Java
body: <p>Was debugging a piece of code and found this strange issue . </p>
  
  <p>On addition of two double variables 0.0040 and 0.0005, Java return me the result as "0.0045000000000000005"</p>
  
  <p>Here's my piece of code :-</p>
  
  <pre><code>    public static void main(String[] args) {
      double a = 0.0040  ;
      double b = 0.0005;
      double result = a+b ;
      System.out.println(result);
  }
  </code></pre>
  
  <p>Output : 0.0045000000000000005 </p>
  
  <p>The output is correct if I give value between 0.0041 to 0.0044 for variable "a" . However, If I give the value to variable "a" as 0.0045  it gives output as "0.004999999999999999".</p>
  
  <p>Help needed !!</p>