如何做浮点比较?
double a = SomeCalculation1();double b = SomeCalculation2();if (a < b) DoSomething2();else if (a > b) DoSomething3();
double a = SomeCalculation3();double b = SomeCalculation4();if (a == 0.0) DoSomethingUseful(1 / a);if (b == 0.0) return 0; // or something else here
double a = 1.0 / 3.0;double b = a + a + a;if ((3 * a) != b) Console.WriteLine("Oh no!");
简而言之,我想知道:如何可靠地比较浮点数(小于,大于等于)?
守着星空守着你
月关宝盒
MM们