C examples for math.h:fdim
function
<cmath> <ctgmath> <math.h>
Returns the positive difference between x and y. The function returns x-y if x>y, and zero otherwise.
long double fdiml (long double x, long double y); long double fdim (long double x, long double y); double fdim (double x , double y); float fdimf (float x , float y); float fdim (float x , float y); double fdim (Type1 x , Type2 y);
Parameter | Description |
---|---|
x | Values whose difference is calculated. |
y | Values whose difference is calculated. |
The positive difference between x and y.
#include <stdio.h> #include <math.h> /* fdim */ int main ()//from w w w. j av a2 s . c o m { printf ("%f\n", fdim(2.0,1.0)); printf ("%f\n", fdim(1.0,1.0)); printf ("%f\n", fdim(1.0,2.0)); printf ("%f\n", fdim(-2.0,-1.0)); printf ("%f\n", fdim(-1.0,-2.0)); return 0; }