nextafter function

double nextafter(
  1. double x,
  2. double y
)

Implementation

double nextafter(double x, double y) {
  if (x.isNaN || y.isNaN) return double.nan;
  if (x == y) return y;
  if (x == 0.0) {
    return y > 0 ? 5e-324 : -5e-324;
  }
  int bits = _doubleBits(x);
  if ((x < y) == (x > 0)) {
    bits += 1;
  } else {
    bits -= 1;
  }
  return _bitsToDouble(bits);
}