The C++ FAQ lite \"[29.17] Why doesn\'t my floating-point comparison work?\" recommends this equality test:
#include /* for std::abs(double) *
You can use std::nextafter with a fixed factor of the epsilon of a value like the following:
bool isNearlyEqual(double a, double b)
{
int factor = /* a fixed factor of epsilon */;
double min_a = a - (a - std::nextafter(a, std::numeric_limits::lowest())) * factor;
double max_a = a + (std::nextafter(a, std::numeric_limits::max()) - a) * factor;
return min_a <= b && max_a >= b;
}