GNU Info

Info Node: (libc.info)Absolute Value

(libc.info)Absolute Value


Next: Normalization Functions Up: Arithmetic Functions
Enter node , (file) or (file)node

Absolute Value
--------------

   These functions are provided for obtaining the "absolute value" (or
"magnitude") of a number.  The absolute value of a real number X is X
if X is positive, -X if X is negative.  For a complex number Z, whose
real part is X and whose imaginary part is Y, the absolute value is
`sqrt (X*X + Y*Y)'.

   Prototypes for `abs', `labs' and `llabs' are in `stdlib.h';
`imaxabs' is declared in `inttypes.h'; `fabs', `fabsf' and `fabsl' are
declared in `math.h'.  `cabs', `cabsf' and `cabsl' are declared in
`complex.h'.

 - Function: int abs (int NUMBER)
 - Function: long int labs (long int NUMBER)
 - Function: long long int llabs (long long int NUMBER)
 - Function: intmax_t imaxabs (intmax_t NUMBER)
     These functions return the absolute value of NUMBER.

     Most computers use a two's complement integer representation, in
     which the absolute value of `INT_MIN' (the smallest possible `int')
     cannot be represented; thus, `abs (INT_MIN)' is not defined.

     `llabs' and `imaxdiv' are new to ISO C99.

     See Note: Integers for a description of the `intmax_t' type.


 - Function: double fabs (double NUMBER)
 - Function: float fabsf (float NUMBER)
 - Function: long double fabsl (long double NUMBER)
     This function returns the absolute value of the floating-point
     number NUMBER.

 - Function: double cabs (complex double Z)
 - Function: float cabsf (complex float Z)
 - Function: long double cabsl (complex long double Z)
     These functions return the absolute  value of the complex number Z
     (Note: Complex Numbers).  The absolute value of a complex number
     is:

          sqrt (creal (Z) * creal (Z) + cimag (Z) * cimag (Z))

     This function should always be used instead of the direct formula
     because it takes special care to avoid losing precision.  It may
     also take advantage of hardware support for this operation. See
     `hypot' in Note: Exponents and Logarithms.


automatically generated by info2www version 1.2.2.9