Copyright © 1997 The Open Group

hypot - Euclidean distance function

`#include <math.h> double hypot(double`

x, doubley);

Thehypot()function computes the length of the hypotenuse of a right-angled triangle:

An application wishing to check for error situations should set

errnoto 0 before callinghypot(). Iferrnois non-zero on return, or the return value is HUGE_VAL or NaN, an error has occurred.

Upon successful completion,hypot()returns the length of the hypotenuse of a right angled triangle with sides of lengthxandy.If the result would cause overflow, HUGE_VAL is returned and

errnomay be set to [ERANGE].If

xoryis NaN, NaN is returned. anderrnomay be set to [EDOM].If the correct result would cause underflow, 0 is returned and

errnomay be set to [ERANGE].

Thehypot()function may fail if:

- [EDOM]
- The value of
xoryis NaN.- [ERANGE]
- The result overflows or underflows.
No other errors will occur.

None.

Thehypot()function takes precautions against overflow during intermediate steps of the computation. If the calculated result would still overflow a double, thenhypot()returns HUGE_VAL.

None.

isnan(),sqrt(),<math.h>.

Derived from Issue 1 of the SVID.

Copyright © 1997 The Open Group

[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]