fabs -- Calculate Floating-Point Absolute Value

Format

#include <math.h>
double fabs(double x);

Language Level: ANSI, POSIX, XPG4
fabs calculates the absolute value of the floating-point argument x.

Return Value
fabs returns the absolute value. There is no error return value.

Example
This example calculates y as the absolute value of x:

#include <math.h>
#include <stdio.h>
int main(void)
{
   double x, y;
   x = -5.6798;
   y = fabs(x);
   printf("fabs( %lf ) = %lf\n", x, y);
   /***************************************
      The output should be similar to:
      fabs( -5.679800 ) = 5.679800
   ***************************************/
}


abs -- Calculate Integer Absolute Value
_cabs -- Calculate Absolute Value of Complex Number
labs -- Calculate Absolute Value of Long Integer
<math.h>