hypot method

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

Computes sqrt(x^2 + y^2) without under/overflow.

Implementation

double hypot(double x, double y) {
  var first = x.abs();
  var second = y.abs();

  if (y > x) {
    first = y.abs();
    second = x.abs();
  }

  if (first == 0.0) {
    return second;
  }

  final t = second / first;

  return first * sqrt(1 + t * t);
}