Previous Page
Next Page

fdim

Obtains the positive difference between 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  );

The fdim( ) function return x - y or 0, whichever is greater. If the implementation has signed zero values, the zero returned by fdim( ) is positive.

Example

/* Make sure an argument is within the domain of asin( ) */

double sign, argument, result;
/* ... */

sign = copysign( 1.0, argument );      // Save the sign ...
argument = copysign( argument, 1.0 );  // ... then use only positive values
argument = 1.0 - fdim( 1.0, argument );     // Trim excess beyond 1.0
result = asin( copysign(argument, sign) );  // Restore sign and call asin( )

See Also

copysign( ), fabs( ), fmax( ), fmin( )


Previous Page
Next Page