fdim
如果x≤y,则fdim函数返回零值,否则返回x - y的值。
接口定义
C interface:
float fdimf(float x, float y);
double fdim(double x, double y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
返回值
- errno:返回值为inf时,置ERANGE。
- 输入x<y时,返回0。
- 输入x>=y时,返回x-y的值。
- 输入x或y为nan时,返回nan。
依赖
C: "km.h"
示例
C interface:
// typical usage printf("fdim(1.0, 2.0) = %.15f\n", fdim(1.0, 2.0)); printf("fdim(3.0, 2.0) = %.15f\n", fdim(3.0, 2.0)); // special handing printf("fdim(INFINITY, INFINITY) = %.15f\n", fdim(INFINITY, INFINITY)); printf("fdim(INFINITY, -INFINITY) = %.15f\n", fdim(INFINITY, -INFINITY)); printf("fdim(-INFINITY, INFINITY) = %.15f\n", fdim(-INFINITY, INFINITY)); printf("fdim(-INFINITY, -INFINITY) = %.15f\n", fdim(-INFINITY, -INFINITY)); printf("fdim(NAN, -INFINITY) = %.15f\n", fdim(NAN, -INFINITY)); result /* * fdim(1.0, 2.0) = 0.000000000000000 * fdim(3.0, 2.0) = 1.000000000000000 * fdim(INFINITY, INFINITY) = 0.000000000000000 * fdim(INFINITY, -INFINITY) = inf * fdim(-INFINITY, INFINITY) = 0.000000000000000 * fdim(-INFINITY, -INFINITY) = 0.000000000000000 * fdim(NAN, -INFINITY) = nan * */
父主题: 杂项函数