nextTowards method

double nextTowards(
  1. double other
)

Returns the nearest double in direction of other. If this is identical to other, other is returned.

Implementation

double nextTowards(double other) {
  if (isNaN || other.isNaN) return double.nan;
  if (this == other) return other;
  if (this < other) return nextUp;
  return nextDown;
}