fabs, fabsf, fabsl

From cppreference.com
< c‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
(C99)
(C99)
(C99)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
(C99)(C99)(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
Types
(C99)(C99)
Macro constants
 
Defined in header <math.h>
float       fabsf( float arg );
(1) (since C99)
double      fabs( double arg );
(2)
long double fabsl( long double arg );
(3) (since C99)
Defined in header <tgmath.h>
#define fabs( arg )
(4) (since C99)
1-3) Computes the absolute value of a floating point value arg.
4) Type-generic macro: If the argument has type long double, fabsl is called. Otherwise, if the argument has integer type or has type double, fabs is called. Otherwise, fabsf is called. If the argument is complex, then the macro invokes the corresponding complex function (cabsf, cabs, cabsl).

Parameters

arg - floating point value

Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

Error handling

This function is not subject to any of the error conditions specified in math_errhandling.

If the implementation supports IEEE floating-point arithmetic (IEC 60559),

  • If the argument is ±0, +0 is returned
  • If the argument is ±∞, +∞ is returned
  • If the argument is NaN, NaN is returned