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


fmax

You can use the fmax function to find out which is the larger of two real numbers.

double_t fmax (double_t x, double_t y);
x
Any floating-point number.
y
Any floating-point number.
DESCRIPTION
The fmax function determines the larger of its two arguments.

fmax(x,y) = x if x y
fmax(x,y) = y if x < y

If one of the arguments is a NaN, the other argument is returned.

EXCEPTIONS
When x and y are finite and nonzero, the result of fmax(x,y) is exact.

SPECIAL CASES
Table 10-2 shows the results when one of the arguments to the fmax function is a zero, a NaN, or an Infinity. In this table, x is a finite, nonzero floating-point number. (Note that the order of operands for this function does not matter.)
Special cases for the fmax function
OperationResultExceptions raised
fmax(+0,x) x if x > 0None
 +0 if x < 0 
fmax(-0,x) x if x > 0None
  -0 if x < 0 
fmax(±0,±0) +0None
fmax(NaN,x) x[21]None[22]
fmax(+ ,x) + None
fmax(- ,x) xNone

EXAMPLES
z = fmax(-INFINITY, -300,000);   /* z = -300,000 because any 
                                    integer is greater than  */
z = fmax(NAN, -300,000);   /* z = -300,000 by definition of the
                              function fmax. */

[21] If both arguments are NaNs, the first NaN is returned.
[22] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996