hypot

Calculates the length of the hypotenuse of a right-angled triangle with sides of length x and y. The hypotenuse is the value of the square root of the sums of the squares of x and y:

sqrt(x2 + y2)

Note that hypot(x, y), hypot(y, x) and hypot(x, -y) are equivalent.

Special Values
xyhypot(x, y)invalid?
x±0.0|x|no
$(PLUSMNINF)y+∞no
$(PLUSMNINF)NaN+∞no
@safe pure nothrow @nogc
real
hypot
(
real x
,
real y
)

Examples

assert(hypot(1.0, 1.0).feqrel(1.4142) > 16);
assert(hypot(3.0, 4.0).feqrel(5.0) > 16);
assert(hypot(real.infinity, 1.0) == real.infinity);
assert(hypot(real.infinity, real.nan) == real.infinity);

Meta

Suggestion Box / Bug Report