Was debugging a piece of code and found this strange issue .
On addition of two double variables 0.0040 and 0.0005, Java return me the result as "0.0045000000000000005"
Here's my piece of code :-
    public static void main(String[] args) {
    double a = 0.0040  ;
    double b = 0.0005;
    double result = a+b ;
    System.out.println(result);
}
Output : 0.0045000000000000005
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".
Help needed !!
 
     
    