Name

abs function — Computes absolute value

Synopsis

float abs(float x)
double abs(double x)
long double abs(long double x)

The abs function returns the absolute value of its argument: if x < 0, it returns -x; otherwise, it returns x.

The abs function in <cmath> is the same as fabs. The <cstdlib> header declares integer versions of the abs function.