relation
You can use therelation
function to determine the relationship (less than, greater than, equal to, or unordered) between two real numbers.
relop relation (double_t x, double_t y);
x
- Any floating-point number.
y
- Any floating-point number.
DESCRIPTION
Therelation
function returns the relationship between its two arguments.The
relation
function is typerelop
, which is an enumerated type. This function returns one of the following values:
if x
>y
GREATERTHAN if x
<y
LESSTHAN if x
=y
EQUALTO if x
ory
is a NaNUNORDERED Programs can use the result of this function in expressions to test for combinations not supported by the comparison operators, such as "less than or unordered."
EXCEPTIONS
When x and y are finite and nonzero, the result of is exact.SPECIAL CASES
Table 10-4 shows the results when one of the arguments to therelation
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 relation
functionOperation Result Exceptions raised < if y > 0 None > if y < 0 None > if x > 0 None < if x < 0 None < if y > 0 None > if y < 0 None > if x > 0 None < if x < 0 None = None Unordered None[25] Unordered None[25] > None < None = None < None > None = None EXAMPLES
r = relation(x, y); if ((r == LESSTHAN) || (r == UNORDERED)) printf("No, y is not greater than x.\n");
[25] If the NaN is a signaling NaN, the invalid exception is raised.