fdiml Function

Calculates the positive difference between the two arguments.

Include

<math.h>

Prototype

long double fdiml(long double x, long double y);

Argument

x
any double precision floating-point number
y
any double precision floating-point number

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)
{
  long double x, y, z;

  errno = 0;
  x = 5.7;
  y = 2.0;
  z = fdiml(x, y);
  if(errno)
    perror("Error");
  printf("The positive difference between %Lf and %Lf is %Lf\n", x, y, z);

  errno = 0;
  x = 3.0;
  y = 4.2;
  z = fdiml(x, y);
  if(errno)
    perror("Error");
  printf("The positive difference between %Lf and %Lf is %Lf\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