+ All Categories
Transcript

abs double abs ( double x );

float abs ( float x );

long double abs ( long double x );

Compute absolute valueReturns the absolute value of x ( /x/ ).

In C++, this function is overloaded in , and (see cstdlib abs, complex abs and valarray abs).

Parameters

x

Floating point value.

Return Value

The absolute value of x.

Portability

These overloads of abs are only available in C++.In C, only the cstdlib version of exists (see cstdlib abs) - fabs can be used instead.

Example

// cmath's abs example

#include

#include

using namespace std;

int main ()

{

cout


Top Related