code: public static double Hypotenuse(double a, double b) {
          double r = 0.0;
          double absA = Math.abs(a);
          double absB = Math.abs(b);
  
          if (absA > absB) {
              r = b / a;
              r = absA * Math.sqrt(1 + r * r);
          } else if (b != 0) {
              r = a / b;
              r = absB * Math.sqrt(1 + r * r);
          }
  
          return r;
      }
docs: Hypotenuse calculus without overflow/underflow.
  
  @param a First value.
  @param b Second value.
  @return The hypotenuse Sqrt(a^2 + b^2).