fmax(3C)
_________________________________________________________________
fmax $builtin function
Determine the maximum value of two floating-point numbers.
_________________________________________________________________
Calling Sequence
double a, b, c, fmax();
a = fmax(b, c);
(or)
$builtin double fmax();
double a, b, c;
a = fmax(b, c);
where a, b, and c are of type double.
Description
Use the fmax function to determine the maximum value of two
floating-point numbers.
The first calling sequence above uses a function call. The
second might generate smaller or faster code, but may not run
under other C compilers.
The include file math.h defines this function and uses the
$builtin version. Using the include file will not cause any
portability problems.
Returns
The fmax function returns the maximum of the two floating-point
numbers you pass to it. Since fmax does no argument checking,
you will never get an error condition.
Related Functions
See also the ceil, floor, fmin, max, and min functions.
Example
/* Program test for the fmax() function */
#include <stdio.h>
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
fmax(3C)
#include <math.h>
int i = 1;
double m, n, o, atof(), fmax();
main(argc, argv)
int argc;
char *argv[];
{
while (i+1 < argc) {
m = atof(argv[i]);
n = atof(argv[i+1]);
printf("fmax of %f and %f = %f\n", m, n, o = fmax(m, n));
i++;
}
}
A call to the program test with the input numbers
6.78e-5
.0001
-3.1416
.0098e3
generates the output
fmax of 0.000068 and 0.000100 = 0.000100
fmax of 0.000100 and -3.141600 = 0.000100
fmax of -3.141600 and 9.800000 = 9.800000
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)