hypot function

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

Implementation

double hypot(double x, double y) {
  x = x.abs();
  y = y.abs();
  if (x.isInfinite || y.isInfinite) return double.infinity;
  if (x < y) {
    double t = x;
    x = y;
    y = t;
  }
  if (x == 0) return 0.0;
  double r = y / x;
  return x * math.sqrt(1 + r * r);
}