Important: The information in this document is obsolete and should not be used for new development.
relation
You can use therelationfunction 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
Therelationfunction returns the relationship between its two arguments.The
relationfunction is typerelop, which is an enumerated type. This function returns one of the following values:
if x>yGREATERTHAN if x<yLESSTHAN if x=yEQUALTO if xoryis 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 therelationfunction is a zero, a NaN, or an Infinity. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the relationfunctionOperation 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.