Format
#include <math.h>
double fabs(double x);
Language Level: ANSI
Threadsafe: Yes.
Description
The fabs() function calculates the absolute value of the floating-point argument x.
Return Value
The fabs() function returns the absolute value. There is no error return value.
Example that uses fabs()
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);
}
/******************* Output should be similar to: ***************
fabs( -5.679800 ) = 5.679800
*/
Related Information