Simply, this is related with binary representation of floating point numbers.
Member 3611002 wrote:
The results of both d and d1 are 37.619999999999997 (unexpected) what do i do to get d=37.62 and d1=37.62
This is normal and there is nothing to do for a double type. if you format that number back using format string %.2f, you will get 37.62 again. I'll try to comment on, shortly. As you may know, double is a 64 bit floating point number. There are some special formats (standards defined by IEEE in this case) to store it in memory. It consists of 3 parts; sign (1), exponent (11), significand (52 bits). There are also special rules for storing exponent and significand. Most important one, exponent part is two's exponent, not ten's. Moreover, some operations (i.e. rounding and normalization) have been applied to a floating point number after every operation. After all, it is stored as nearest possible value fitting into these rules.