fmax
返回入参的最大值。
接口定义
C interface:
float fmaxf(float x, float y);
double fmax(double x, double y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回x,y中的较大值。
- 其他特殊值参考如下说明。
输入值(x) |
输入值(y) |
返回值 |
---|---|---|
any |
qnan |
x |
qnan |
any |
y |
any |
snan |
nan |
snan |
any |
nan |
依赖
C: "km.h"
示例
C interface:
// 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 handing 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 * */
父主题: 杂项函数