HYPOT(3M) HYPOT(3M)
hypot, hypotf, fhypot, hypotl, cabs, cabsf, fcabs, cabsl  Euclidean
distance, complex absolute value
#include <math.h>
double hypot (double x, double y);
float fhypot (float x, float y);
float hypotf (float x, float y);
long double hypotl (long double x, long double y);
double cabs (struct { double a,b; } z);
float fcabs (struct { float a,b; } z);
float cabsf (struct { float a,b; } z);
long double cabsl (struct { long double a,b; } z);
hypot(x,y), fhypot(x,y), hypotf(x,y), hypotl(x,y), cabs(x,y), fcabs(x,y),
cabsf(x,y), and cabsl(x,y) return sqrt(x*x+y*y) computed in such a way
that overflow will not happen, and underflow occurs only if the final
result deserves it.
fhypot, hypotf, fcabs, and cabsf are the same functions as hypot and cabs
but for the float data type.
hypotl, and cabsl are the same functions as hypot and cabs but for the
long double data type.
In the diagnostics below, functions in the standard math library libm.a,
are referred to as lm versions, those in libmx.a are referred to as lmx
versions, and those in the the BSD math library libm43.a, are referred to
as lm43 versions. The lm and lmx versions always return the default
Quiet NaN and set errno to EDOM when a NaN is used as an argument. A NaN
argument causes the lm43 versions of the hypot functions to return the
same NaN, unless the other argument is HUGE_VAL, in which case HUGE_VAL
is returned. The lm43 versions never set errno. The value of HUGE_VAL
is IEEE Infinity.
When the correct value would overflow, the hypot functions return
HUGE_VAL The lm and lmx versions also set errno to ERANGE. See
matherr(3M) for a description of error handling for lmx functions.
Long double operations on this system are only supported in round to
nearest rounding mode (the default). The system must be in round to
nearest rounding mode when calling any of the long double functions, or
incorrect answers will result.
Page 1
HYPOT(3M) HYPOT(3M)
Users concerned with portability to other computer systems should note
that the long double and float versions of these functions are optional
according to the ANSI C Programming Language Specification ISO/IEC 9899 :
1990 (E).
Long double functions have been renamed to be compliant with the ANSIC
standard, however to be backward compatible, they may still be called
with the double precision function name prefixed with a q.
hypot and cabs are not ANSIC functions. If you compile with flag ansi,
you must supply your own prototypes for these functions or you will get
incorrect results. (See the prototypes defined in /usr/include/math.h)
ERROR (due to Roundoff, etc.)
Below 0.97 ulps. Consequently hypot(5.0,12.0) = 13.0 exactly; in
general, hypot and cabs return an integer whenever an integer might be
expected.
math(3M), sqrt(3M), matherr(3M)
W. Kahan
PPPPaaaaggggeeee 2222 [ Back ]
