fabs, fabsf, fabsl


For the latest documentation on Visual Studio 2017, see Visual Studio 2017 Documentation.

Calculates the absolute value of the floating-point argument.

double fabs(   
   double x   
float fabs(  
   float x   
); // C++ only  
long double fabs(  
   long double x  
); // C++ only  
float fabsf(   
   float x   
long double fabsl(  
   long double x  


Floating-point value.

The fabs functions return the absolute value of the argument x. There is no error return.

InputSEH ExceptionMatherr Exception

C++ allows overloading, so you can call overloads of fabs if you include the <cmath> header. In a C program, fabs always takes and returns a double.

FunctionRequired C headerRequired C++ header
fabs, fabsf, fabsl<math.h><cmath> or <math.h>

For additional compatibility information, see Compatibility in the Introduction.

See the example for abs.

Floating-Point Support
abs, labs, llabs, _abs64
labs, llabs