fdim()

Computes the positive difference of two numbers.

  #include <math.h>
  
  double fdim(double x, double y);
  
  float fdimf(float x, float y);
  
  long double fdiml(long double x, long double y);    
Parameter

x

The minuend.

y

The subtrahend.

Remarks

If x is greater or equal to y, the functions returns x - y. If x is less than y, the functions set errno to ERANGE and fpclassify(fdim(x, x)) does not return FP_NORMAL.

This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.

Listing: Example of fdim() usage

#include <math.h>

#include <stdio.h>

int main(void)

{

double k = 12;

double l = 4;

printf("|(%f - %f)| = %f\n", k, l, fdim(k,l));

return 0;

}

Output:

| ( 12.000000 - 4.0000000 ) | = 8.0000000