Q:

Value changes when using double to store the value in c++ but remains same in java

I have similar code in c++ and java. There is a call by value to a double variable. I pass on a value of 1680.175 to both the codes. I can see during debugging that the value when passed changes to 1680.1749999999902 in c++ while it remains the same in java. I have to round a value after two places of decimal and therefore the codes give different result. 

A:

The value didn't change at all, you just printed it such that the extra decimals showed. The value 1680.175 does not have an exact representation in the double floating-point notation and the closest value is 1680.1749999999902. The same thing goes on in Java.

