I am getting a weird problem while parsing a double value in managed C++. It may be that I am doing something wrong. When I do:
double value = 0.006;
result = Math::Parse( value)
The output of result is 0.006000000000001
. Why it is appending a 1?
Also when I go an round the value to 5 decimal places, it fails. I am doing:
result2 = Math::Round(result, 5)
But result2
is always 0.006000000000001
. What am I doing wrong?
It is normal. This problem caused by IEEE format of double - in real 0.006 is represented as approximation of infinite binary fraction. So you have 3 ways -