Table of Contents

fabs

    double fabs(double);

calculates the absolute number of a given value

cpp Sourcecode Example

#include <iostream> /* including standard library */
#include <cmath> /* including math library */
 
using namespace std;
int main ( void ) 
{
    double y,x;
    x = 4.2422;
    y = -3284.2;
 
    //cout.setf(ios::fixed, ios::floatfield);
    cout.precision(8);
 
    cout << "the fabs of 4.2422 is " << fabs(x) << endl;
    cout << "and the fabs of -3284.2 is " <<  fabs(y) << endl;
    return 0;
}

output

 the fabs of 4.2422 is 4.2422
 and the fabs of -3284.2 is 3284.2