import std.math.operations : feqrel; import std.math.traits : isNaN; 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(1.0L, real.infinity) == real.infinity); assert(hypot(real.infinity, real.nan) == real.infinity); assert(hypot(real.nan, real.infinity) == real.infinity); assert(hypot(real.nan, 1.0L).isNaN); assert(hypot(1.0L, real.nan).isNaN);
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.