Calculates the positive difference between the two arguments.
Include
<math.h>
Prototype
float fdimf(float x, float y);
Argument
x
y
Return Value
Returns the positive difference between the two argument, that being
x - y
when x
is larger than y
,
and 0 for all other values of x
.
Remarks
A range error might occur.
Example
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
float x, y, z;
errno = 0;
x = 5.7;
y = 2.0;
z = fdimf(x, y);
if(errno)
perror("Error");
printf("The positive difference between %f and %f is %f\n", x, y, z);
errno = 0;
x = 3.0;
y = 4.2;
z = fdimf(x, y);
if(errno)
perror("Error");
printf("The positive difference between %f and %f is %f\n", x, y, z);
}
Example Output
The positive difference between 5.700000 and 2.000000 is 3.700000
The positive difference between 3.000000 and 4.200000 is 0.000000