I get this code snippet from some where else. According to the webmaster, the code is picked from The art of computer programming by Knuth
Since I do not have a copy of that book, may I know what is the difference among the two functions?
bool approximatelyEqual(float a, float b, float epsilon)
{
return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool essentiallyEqual(float a, float b, float epsilon)
{
return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}