Most of my work thus far hasn't had much to do with floating point precision, I'm sure I would have found some of that info if I was ever required to.
double compare 0.2 != 0.2 How?
Collapse
X
-
-
That is how things work, the only thing you can do is add a handy extension method to System.Double, something like:
Code:public static bool AlmostEquals (this double a, double b) { return (Math.Abs(a - b) < 1e-5); }
Code:MessageBox.Show((1.0 - 0.8).AlmostEquals(0.2));
Comment
-
That is how things work, the only thing you can do is add a handy extension method to System.Double, something like:
Code:public static bool AlmostEquals (this double a, double b) { return (Math.Abs(a - b) < 1e-5); }
Code:MessageBox.Show((1.0 - 0.8).AlmostEquals(0.2));
Comment
Comment