fmax
Return the maximum value of the input parameters.
Interface Definition
C interface:
float fmaxf(float x, float y);
double fmax(double x, double y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- The larger value between x and y is returned.
- For special values, see the following table.
Input Value (x) |
Input Value (y) |
Return Value |
|---|---|---|
any |
qnan |
x |
qnan |
any |
y |
any |
snan |
nan |
snan |
any |
nan |
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | // typical usage double x1 = 0.0, x2 = -0.0, x3 = 1.4, x4 = -2.7; double y1 = -0.0, y2 = 0.0, y3 = 1.5, y4 = -2.1; // special handling double a = INFINITY, b = -INFINITY, c = NAN; printf("fmax(0.0, -0.0) = %.15f\n", fmax(x1, y1)); printf("fmax(-0.0, 0.0) = %.15f\n", fmax(x2, y2)); printf("fmax(1.4, 1.5) = %.15f\n", fmax(x3, y3)); printf("fmax(-2.7, -2.1) = %.15f\n", fmax(x4, y4)); printf("fmax(INFINITY, 1.4) = %.15f\n", fmax(a, x3)); printf("fmax(-INFINITY, -2.7) = %.15f\n", fmax(b, x4)); printf("fmax(NAN, 1.4) = %.15f\n", fmax(c, x3)); printf("fmax(NAN, INFINITY) = %.15f\n", fmax(c, a)); printf("fmax(NAN, -INFINITY) = %.15f\n", fmax(c, b)); printf("fmax(INFINITY, -INFINITY) = %.15f\n", fmax(a, b)); /* * fmax(0.0, -0.0) = 0.000000000000000 * fmax(-0.0, 0.0) = 0.000000000000000 * fmax(1.4, 1.5) = 1.500000000000000 * fmax(-2.7, -2.1) = -2.100000000000000 * fmax(INFINITY, 1.4) = inf * fmax(-INFINITY, -2.7) = -2.700000000000000 * fmax(NAN, 1.4) = 1.400000000000000 * fmax(NAN, INFINITY) = inf * fmax(NAN, -INFINITY) = -inf * fmax(INFINITY, -INFINITY) = inf * */ |
Parent topic: Miscellaneous Functions