isLargerNumbersBetween function

bool isLargerNumbersBetween (double a, double b, int maxNumbersBetween)

Compares two doubles and determines if the a value is larger than the b value to within the tolerance or not. Equality comparison is based on the binary representation.

Implementation

bool isLargerNumbersBetween(double a, double b, int maxNumbersBetween) {
  // If A or B are a NAN, return false. NANs are equal to nothing,
  // not even themselves, and thus they're not bigger or
  // smaller than anything either
  if (a.isNaN || b.isNaN) {
    return false;
  }

  return compareToNumbersBetween(a, b, maxNumbersBetween) > 0;
}