fabs
double  fabs ( double x );
math.h
  cplusplus.com  

Return absolute value of floating-point.
  Returns the absoulte value of parameter x. /x/

Parameters.

x
Floating point value.

Return Value.
  Absoulte value of x.

Portability.
  Defined in ANSI-C.
  ANSI-C++ adds float and double overloaded versions of this function, with the same bahavior but being both, parameter and result, of one of these types.

Example.

/* fabs example */
#include <stdio.h>
#include <math.h>

main ()
{
  printf ("Absoulte value of 3.1416 is %lf\n", fabs (3.1416) );
  printf ("Absoulte value of -10.6 is %lf\n", fabs (-10.6) );
  return 0;
}
Output:
Absolute value of 3.1416 is 3.141600
Absoulte value of -10.6 is 10.600000

See also.
  abs, labs


© The C++ Resources Network, 2000