floating-point absolute value function

You're viewing an older version of this page (#3244). View the current version.

View versions (3)

NAME

fabs

INTERFACE

#include <math.h>

double fabs ( double x ) long fabsl ( long double x ) float fabsf ( float x )

DESCRIPTION

The fabs functions compute the absolute value of a floating-point number x.

Example 1

#include <stdio.h>
#include <math.h>

int main(void)
{
  float number = -1234.0;
  printf("number: %f   absolute value: %f\n", number, fabs(number));
  return 0;
}

SPECIAL VALUES

fabs ( &plusmn;0 ) returns 0.

fabs ( &plusmn;&infin; ) returns +&infin;.

SEE ALSO

abs (3) , ceil (3) , floor (3)

STANDARDS

The fabs functions conform to ISO/IEC 9899:1999(E).