HP C/iX Library Reference Manual (30026-90004)

140 Chapter5
HP C/iX Library Function Descriptions
fabs
fabs
Computes the absolute value of a floating-point argument.
Syntax
#include <math.h>
double fabs (double
x
);
Parameters
x
A floating-point value whose absolute value is to be computed.
Return Values
n The absolute value of the floating-point value specified in
x
.
Example
The following program calculates floating-point absolute values until a zero is entered
from the keyboard:
#include <math.h>
main()
{
double value, fabs();
do
{
printf("Enter value: ");
scanf("%lf", &value);
if (value == 0)
exit
printf("Absolute value of %.12g is %.12g.\n", value, fabs(value));
}
while (value !=0);
}
See Also
abs(), labs(), ANSI C 4.5.6.2, POSIX.1 8.1