So, I made this lines of code to return 10% of the value in the parameter. For example, if the value being given is 7, the code should return 0.7. But it is returning 0.7000000000000001. Any thoughts why? The code is below:
public double calculateDiscount(double price){
double discount;
discount = price*0.10;
return discount;
}
I'm using eclipse IDE, and using the debug, I didn't find anything weird, the multiplication is simply returning that huge number.
PS.: I know that I can return only two decimal cases, but I want to know whats going on.
PPS.: Using /10 instead of *0.10 works just fine. But, as I said, I want to know why.