A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/cmath/fabs/ below:

function

<cmath> <ctgmath>

fabs
     double fabs  (double x);      float fabsf (float x);long double fabsl (long double x);
     double fabs (double x);      float fabs (float x);long double fabs (long double x);
     double fabs (double x);      float fabs (float x);long double fabs (long double x);     double fabs (T x);           // additional overloads for integral types

Compute absolute value

Returns the absolute value of x: |x|.

Header

<tgmath.h>

provides a type-generic macro version of this function.


Additional overloads

are provided in this header (

<cmath>

) for the

integral types

: These overloads effectively cast

x

to a

double

(defined for

T

being any

integral type

).



Parameters
x
Value whose absolute value is returned.

Return Value The absolute value of x.

Example
1
2
3
4
5
6
7
8
9
10
/* fabs example */
#include <stdio.h>      /* printf */
#include <math.h>       /* fabs */

int main ()
{
  printf ("The absolute value of 3.1416 is %f\n", fabs (3.1416) );
  printf ("The absolute value of -10.6 is %f\n", fabs (-10.6) );
  return 0;
}

Output:
The absolute value of 3.1416 is 3.141600
The absolute value of -10.6 is 10.600000


See also
abs
Absolute value (function)
labs
Absolute value (function)
floor
Round down value (function)
ceil
Round up value (function)
modf
Break into fractional and integral parts (function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4