withinRounding method

bool withinRounding(
  1. FloatingPointValue other
)

Return true if the other FloatingPointValue is within a rounding error of this value.

Implementation

bool withinRounding(FloatingPointValue other) {
  if (this != other) {
    final diff = (abs() - other.abs()).abs();
    if (diff.compareTo(ulp()) == 1) {
      return false;
    }
  }
  return true;
}