bool almost_equal(double a, double b, double epsilon = 0.000000001)
{
return std::abs(a - b) < epsilon;
}
HOWEVER, the best solution here is to not make a comparison in the first place.
Please tell us why you are trying to exactly compare floating-point numbers.
There are most likely alternatives here that avoid comparing floating-point numbers for equality.