title | description | ms.date | api_name | api_location | api_type | topic_type | f1_keywords | helpviewer_keywords | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fabs, fabsf, fabsl | API reference for fabs, fabsf, and fabsl; which calculate the absolute value of a floating-point value. | 1/15/2021 |
|
|
|
|
|
|
Calculates the absolute value of the floating-point argument.
doublefabs( doublex ); floatfabs( floatx ); // C++ onlylong doublefabs( long doublex ); // C++ onlyfloatfabsf( floatx ); long doublefabsl( long doublex ); #definefabs(X) // Requires C11 or higher
x
Floating-point value.
The fabs
functions return the absolute value of the argument x
. There's no error return.
Input | SEH exception | _matherr exception |
---|---|---|
± QNaN, IND | none | _DOMAIN |
C++ allows overloading, so you can call overloads of fabs
if you include the <cmath>
header. In a C program, unless you're using the <tgmath.h>
macro to call this function, fabs
always takes and returns a double
.
If you use the fabs
macro from <tgmath.h>
, the type of the argument determines which version of the function is selected. See Type-generic math for details.
By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.
Function | Required C header | Required C++ header |
---|---|---|
fabs , fabsf , fabsl | <math.h> | <cmath> or <math.h> |
fabs macro | <tgmath.h> |
For more compatibility information, see Compatibility.
See the example for abs
.
Math and floating-point supportabs
, labs
, llabs
, _abs64
_cabs