Is double Multiplication Broken in .NET?

Viewed 24069

If I execute the following expression in C#:

double i = 10*0.69;

i is: 6.8999999999999995. Why?

I understand numbers such as 1/3 can be hard to represent in binary as it has infinite recurring decimal places but this is not the case for 0.69. And 0.69 can easily be represented in binary, one binary number for 69 and another to denote the position of the decimal place.

How do I work around this? Use the decimal type?

6 Answers
Related