G
Guest
Hi there
I'm using the Visual Studio .NET 2003 -> C#.
If i try to subtract 145.05 - 140.0 i will get 5.050000000001.
Why isn't the result 5.05?
My testcode is:
double a = 145.05;
double b = 140;
double c = 0;
c = a - b;
this.txtResult.Text = c.ToString();
I thought that could be a failure of the conversion of the ToString method, so i used the debugger to find out where the problem is, but the var "c" is 5.05000000001.
Does anybody know how i can fix this?
Could that be a failure of my processor (Intel P4 HyperThreading), or is that a failure of the .NET Framework?
I hope someone can help me to fix this.
Thanks a lot & Best Regards
Clever & Smart
I'm using the Visual Studio .NET 2003 -> C#.
If i try to subtract 145.05 - 140.0 i will get 5.050000000001.
Why isn't the result 5.05?
My testcode is:
double a = 145.05;
double b = 140;
double c = 0;
c = a - b;
this.txtResult.Text = c.ToString();
I thought that could be a failure of the conversion of the ToString method, so i used the debugger to find out where the problem is, but the var "c" is 5.05000000001.
Does anybody know how i can fix this?
Could that be a failure of my processor (Intel P4 HyperThreading), or is that a failure of the .NET Framework?
I hope someone can help me to fix this.
Thanks a lot & Best Regards
Clever & Smart