FABS(3) Library Functions Manual FABS(3)

fabsfloating-point absolute value function

#include <math.h>

double
fabs(double x);

long double
fabsl(long double x);

float
fabsf(float x);

The () functions compute the absolute value of a floating-point number x.

fabs(±0) returns 0.

(±infinity) returns +infinity.

If you need to apply the fabs() function to SIMD vectors or arrays, using the following functions provided by the Accelerate.framework may give significantly better performance:

#include <Accelerate/Accelerate.h>

vFloat (vFloat x);
void ( float *y, const float *x, const int *n);
void (double *y, const double *x, const int *n);

abs(3), ceil(3), floor(3), rint(3), math(3)

The fabs() functions conform to ISO/IEC 9899:2011.

December 11, 2006 Mac OS X 12