#### 20.8.1 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`, `llabs`, `uabs`, `ulabs` and `ullabs` are in `stdlib.h`; `imaxabs` and `umaxabs` are declared in `inttypes.h`; the `fabs` functions are declared in `math.h`; the `cabs` functions 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: `unsigned int` uabs `(int number)` ¶
Function: `unsigned long int` ulabs `(long int number)` ¶
Function: `unsigned long long int` ullabs `(long long int number)` ¶
Function: `intmax_t` imaxabs `(intmax_t number)` ¶
Function: `uintmax_t` umaxabs `(intmax_t number)` ¶

  Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

  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. Using `uabs` avoids this.

  `llabs` and `imaxdiv` are new to ISO C99. `uabs`, `ulabs`, `ullabs` and `umaxabs` are new to ISO C2Y.

  See 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)` ¶
Function: `_FloatN` fabsfN `(_FloatN number)` ¶
Function: `_FloatNx` fabsfNx `(_FloatNx number)` ¶

  Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

  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)` ¶
Function: `_FloatN` cabsfN `(complex _FloatN z)` ¶
Function: `_FloatNx` cabsfNx `(complex _FloatNx z)` ¶

  Preliminary: | MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

  These functions return the absolute value of the complex number z (see 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 Exponentiation and Logarithms.