Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Math.hypot

Math.hypot(x, y) → Float

Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled triangle with sides x and y.

Example
Math.hypot(3, 4)   #=> 5.0
See also .gamma .ldexp .frexp .lgamma also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0