User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







cpp:cmath:fabs

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
advertising
cpp/cmath/fabs.txt · Last modified: 2012/10/12 18:35 (external edit)

Impressum Datenschutz