Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Comparison Functions


relation

You can use the relation 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
The relation function returns the relationship between its two arguments.

The relation function is type relop, which is an enumerated type. This function returns one of the following values:
if x > yGREATERTHAN
if x < yLESSTHAN
if x = yEQUALTO
if x or y 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 relation(x,y) is exact.

SPECIAL CASES
Table 10-4 shows the results when one of the arguments to the relation 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 function
OperationResultExceptions raised
relation(+0,y) < if y > 0None
 > if y < 0None
relation(x,+0) > if x > 0None
 < if x < 0None
relation(-0,y) < if y > 0None
 > if y < 0None
relation(x,-0) > if x > 0None
 < if x < 0None
relation(+0,-0) =None
relation(NaN,y) UnorderedNone[25]
relation(x,NaN) UnorderedNone[25]
relation(+ ,y) >None
relation(x,+ ) <None
relation(+ ,+ ) =None
relation(- ,y) <None
relation(x,- ) >None
relation(- ,- ) =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.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996