Computes the Euclidean distance function and complex absolute value.
IEEE Math Library (libm.a) System V Math Library (libmsaa.a)
The hypot, hypotf, hypotl, hypotd32, hypotd64, and hypotd128 subroutines compute the value of the square root of x2 + y2 without undue overflow or underflow.
An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.
Item | Description |
---|---|
x | Specifies some double-precision floating-point value. |
y | Specifies some double-precision floating-point value. |
Upon successful completion, the hypot, hypotf, hypotl, hypotd32, hypotd64, and hypotd128 subroutines return the length of the hypotenuse of a right-angled triangle with sides of length x and y.
If the correct value would cause overflow, a range error occurs and the hypotf, hypotl, hypotd32, hypotd64, and hypotd128 subroutines return the value of the macro HUGE_VALF, HUGE_VALL, HUGE_VAL_D32, HUGE_VAL_D64, and HUGE_VAL_D128 respectively.
If x or y is ±Inf, +Inf is returned (even if one of x or y is NaN).
If x or y is NaN, and the other is not ±Inf, a NaN is returned.
If both arguments are subnormal and the correct result is subnormal, a range error may occur and the correct result is returned.
When using the libm.a (-lm) library, if the correct value overflows, the hypot subroutine returns a HUGE_VAL value.
When using libmsaa.a (-lmsaa), if the correct value overflows, the hypot subroutine returns HUGE_VAL and sets the global variable errno to ERANGE.
These error-handling procedures may be changed with the matherr subroutine when using the libmsaa.a (-lmsaa) library.