Important: The information in this document is obsolete and should not be used for new development.
fdim
You can use thefdim
function to determine the positive difference between two real numbers.
double_t fdim (double_t x, double_t y);
x
- Any floating-point number.
y
- Any floating-point number.
DESCRIPTION
Thefdim
function returns the positive difference between its two arguments.if x > y
if x yEXCEPTIONS
When x and y are finite and nonzero and x > y, either the result of is exact or it raises one of the following exceptions:
- inexact (if the result of x - y must be rounded)
- overflow (if the result of x - y is outside the range of the data type)
- underflow (if the result of x - y is inexact and must be represented as a denormalized number or 0)
SPECIAL CASES
Table 10-1 shows the results when one of the arguments to thefdim
function is a zero, a NaN, or an Infinity. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the fdim
functionOperation Result Exceptions raised +0 None x None +0 None x None NaN[19] None[20] NaN None + None +0 None +0 None + None EXAMPLES
z = fdim(+INFINITY, 300); /* z = + - 300 = +INFINITY because + > 300 */ z = fdim(300, +INFINITY); /* z = +0 because 300 + */
[19] If both arguments are NaN, the first NaN is returned.
[20] If the NaN is a signaling NaN, the invalid exception is raised.