fdiml Function

Calculates the positive difference between two long double-precision floating-point arguments.

Include

<math.h>

Prototype

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

Arguments

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

Return Value

Returns the positive difference between the two arguments, that being x - y when x is larger than y, and 0 for all other values of x.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#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