Double give me wrong value after it was calculated multiple times

 
I get the open price value from the selected position. Assume that the selected position price I got is 0.20 Then I sum it up with 0.1. So, I got 0.30 for the first calculation. When I do it multiple times until the value is 0.50. When I do the calculation for 0.5 (plus with 0.1 again), I got 0.5000000001. What was happenned and what should I do to deal with this situation.

Thank you
 
Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 programming forum

Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

 
William Roeder:
Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia, the free encyclopedia

See also The == operand. - MQL4 programming forum

Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

Thank you for sharing. Appreciate :)