The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

hypot - Euclidean distance function

 SYNOPSIS



#include <math.h>

double hypot(double x, double y);

 DESCRIPTION

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

An application wishing to check for error situations should set errno to 0 before calling hypot(). If errno is non-zero on return, or the return value is HUGE_VAL or NaN, an error has occurred.

 RETURN VALUE

Upon successful completion, hypot() returns the length of the hypotenuse of a right angled triangle with sides of length x and y.

If the result would cause overflow, HUGE_VAL is returned and errno may be set to [ERANGE].

If x or y is NaN, NaN is returned. and errno may be set to [EDOM].

If the correct result would cause underflow, 0 is returned and errno may be set to [ERANGE].

 ERRORS

The hypot() function may fail if:
[EDOM]
The value of x or y is NaN.
[ERANGE]
The result overflows or underflows.

No other errors will occur.

 EXAMPLES

None.

 APPLICATION USAGE

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

 FUTURE DIRECTIONS

None.

 SEE ALSO

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

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]