C examples for math.h:fabs
function
<cmath> <ctgmath> <math.h>
Returns the absolute value of x: |x|.
long double fabsl (long double x); long double fabs (long double x); double fabs (double x); float fabsf (float x); float fabs (float x); double fabs (T x);
Parameter | Description |
---|---|
x | Value whose absolute value is returned. |
The absolute value of x.
#include <stdio.h> #include <math.h> /* fabs */ int main ()/*from w w w .j av a 2 s . c o m*/ { printf ("%f\n", fabs (3.1416) ); printf ("%f\n", fabs (-10.6) ); printf ("%f\n", fabs (-0.6) ); printf ("%f\n", fabs (-0.0) ); return 0; }