Name
fdim
Synopsis
Obtains the positive difference between two numbers
#include <math.h> doublefdim
( doublex
, doubley
); floatfdimf
( floatx
, floaty
); long doublefdiml
( long doublex
, long doubley
);
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
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.