Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 2.35 KB

fabs-fabsf-fabsl.md

File metadata and controls

76 lines (56 loc) · 2.35 KB
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
fabsf
fabs
fabsl
_o_fabs
_o_fabsf
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
DLLExport
apiref
fabs
fabsf
fabsl
math abs
math absf
math absl
absolute values
fabsf function
calculating absolute values
fabs function
fabsl function

fabs, fabsf, fabsl

Calculates the absolute value of the floating-point argument.

Syntax

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

#define fabs(X) // Requires C11 or higher

Parameters

x
Floating-point value.

Return 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

Remarks

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.

Requirements

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.

Example

See the example for abs.

See also

Math and floating-point support
abs, labs, llabs, _abs64
_cabs