hypot method

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

Computes the square root of the sum of the squares of x and y without undue overflow or underflow.

Implementation

double hypot(double x, double y) {
  if (x == 0) return y.abs();
  if (y == 0) return x.abs();
  final double maxAbs = dart_math.max(x.abs(), y.abs());
  final double minAbs = dart_math.min(x.abs(), y.abs());
  final double ratio = minAbs / maxAbs;
  return maxAbs * dart_math.sqrt(1.0 + ratio * ratio);
}