class method
Math.hypot
(::Math::double x, ::Math::double y) -> ::Float
Math.hypot(a, b) → float
math.c
View on GitHub ↗
static VALUE
math_hypot(VALUE unused_obj, VALUE x, VALUE y)
{
return DBL2NUM(hypot(Get_Double(x), Get_Double(y)));
}
Returns sqrt(a**2 + b**2), which is the length of the longest side c (the hypotenuse) of the right triangle whose other sides have lengths a and b.
-
Domain of
a:[-INFINITY, INFINITY]. -
Domain of +ab:
[-INFINITY, INFINITY]. -
Range:
[0, INFINITY].
Examples:
Example
hypot(0.0, 1.0) # => 1.0 hypot(1.0, 1.0) # => 1.4142135623730951 # sqrt(2.0) hypot(3.0, 4.0) # => 5.0 hypot(5.0, 12.0) # => 13.0 hypot(1.0, sqrt(3.0)) # => 1.9999999999999998 # Near 2.0
Note that if either argument is INFINITY or -INFINITY, the result is Infinity.