The OpenD Programming Language

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
  1. T hypot(T x, T y)
    @safe pure nothrow @nogc
    T
    hypot
    (
    T
    )
    (
    const T x
    ,
    const T y
    )
  2. T hypot(T x, T y, T z)

Examples

import std.math.operations : feqrel;

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.0L) == real.infinity);
assert(hypot(real.infinity, real.nan) == real.infinity);

Meta