Does “epsilon” really guarantees anything in floating-point computations?
问题 To make the problem short let's say I want to compute the expression a / (b - c) on float s. To make sure the result is meaningful, I can check if b and c are in equal: float EPS = std::numeric_limits<float>::epsilon(); if ((b - c) > EPS || (c - b) > EPS) { return a / (b - c); } but my tests show it is not enough to guarantee either meaningful results nor not failing to provide a result if it is possible. Case 1: a = 1.0f; b = 0.00000003f; c = 0.00000002f; Result: The if condition is NOT met,