isZeroWidth static method

bool isZeroWidth(
  1. double minValue,
  2. double maxValue
)

Computes whether the interval min, max is effectively zero width. I.e. the width of the interval is so much less than the location of the interval that the midpoint of the interval cannot be represented precisely. /

Implementation

static bool isZeroWidth(double minValue, double maxValue) {
  double width = maxValue - minValue;
  if (width == 0.0) return true;
  minValue = minValue.abs();
  maxValue = maxValue.abs();
  double maxAbs = maxValue >= minValue ? maxValue : minValue;
  double scaledInterval = width / maxAbs;
  int level = DoubleBits.exponent(scaledInterval);
  return level <= MIN_BINARY_EXPONENT;
}