#include <cmath> double fabs( double arg );
The function fabs() returns the absolute value of arg.
C++ also provides the following overloaded forms:
#include <cmath> float fabs( float arg ); // same as fabsf() in C99 long double fabs( long double arg ); // same as fabsl() in C99
You can also use abs() instead of fabs() in C++, as it contains overloaded versions for it.