I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
ComputingCMath.h

fabsl

Floating-point absolute value function
+ View other versions (3)

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, which is given by:

Example:

Example - Floating-point absolute value function
Workings
#include <stdio.h>
#include <math.h>
int main(void)
{
  float number = -1234.0;
  printf("number: %.2f   absolute value: %.2f\n", number, fabs(number));
  return 0;
}
Solution
Output:
number: -1234.00   absolute value: 1234.00

Special Values

fabs ( ±0 ) returns 0.

fabs ( ±∞ ) returns +∞.

Standards

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