Name

fabs, fabsf, fabsl
- absolute value of floating-point number

Library

libm.lib

Synopsis

  #include <math.h>
  double fabs (double x);
  float fabsf (float x);
  long double fabsl (long double x);

Return values

The fabs, fabsf and fabsl functions return the absolute value of x.

Detailed description

The fabs, fabsf and fabsl functions compute the absolute value of a floating-point number x.

Examples

#include  <stdio.h>
#include  <math.h>
int main( void )
{
   double dx = -3.141593, dy;
   dy = fabs( dx );
   printf( "fabs( %f ) = %f\n", dx, dy );
   dy = fabsf( dx );
   printf( "fabsf( %f ) = %f\n", dx, dy );
   dy = fabsl( dx );
   printf( "fabsl( %f ) = %f\n", dx, dy );
}

         

Output

fabs( -3.141593  ) = 3.141593
fabsf( -3.141593 ) = 3.141593
fabsl( -3.141593 ) = 3.141593

         


See also

abs, ceil, floor, ieee, math, rint

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top