fabs, fabsf, fabsl

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at fabs, fabsf, fabsl.

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  
);  

Parameters

x
Floating-point value.

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

InputSEH ExceptionMatherr Exception
± QNAN,INDnone_DOMAIN

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
_cabs
labs, llabs

Show: