HYPOT(3M)HYPOT(3M)


NAME
     cabs, hypot, cabsf, hypotf, cabsl, hypotl - Euclidean distance,
     complex absolute value

SYNOPSIS
     #include <math.h>

     double cabs (double complex z);
     float cabsf (float complex z };
     long double cabsl (long double complex z);

     double hypot (double x, double y);
     float hypotf (float x, float y);
     long double hypotl (long double x, long double y);

DESCRIPTION
     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.

     Alternate entries exist for some routines.  For example, qhypot is an
     alternate entry name for hypotl.

     hypotf 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.

     The c89 library also had functions cabs, cabsf, and cabsl with the
     following prototypes:

          double cabs (struct {double a,b; } z);
          float cabsf (struct {float a,b; } z);
          long double cabs (struct {long double a,b; } z);

     In order to preserve forward compatability of these functions, it is
     possible to use either the c89 or the c99 definitions of the cabs
     functions simply by including <complex.h> for the c99 versions (and
     compiling with the -c99 option) or by including <math.h> for the c89
     versions (and compiling without -c99). If possible, change to the c99
     versons of these functions by changing the source code and
     recompiling. The functionality is the same as in the c89 version.

     In c89, fcabs is an alternate name for cabsf and fhypot is an
     alternate name for hypotf.

NOTES
     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.

     Users concerned with portability to other computer systems should note
     that the long double and float versions of these functions were
     optional according to the ANSI C Programming Language Specification
     ISO/IEC 9899 : 1990 (E) and are not longer optional according to
     ISO/IEC 9899:1999(E).

     Long double functions have been renamed to be compliant with the
     ANSI-C 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 ANSI-C functions.  If you compile with the
     -ansi option, you must supply your own prototypes for these functions
     or you get incorrect results.  (See the prototypes defined in
     /usr/include/math.h).

   Errors
     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.

RETURN VALUES
     Functions in the standard math library libm.a are referred to as -lm
     versions. Those in libmx.a are referred to as -lmx versions. 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.

SEE ALSO
     math(3M), sqrt(3M), matherr(3M)