finite
判断输入值x是否为有限数,返回值类型为整型数。
接口定义
C interface:
int finitef(float x);
int finite(double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回判断x是否为有限数。
- 输入浮点数,返回1。
- 输入±∞,返回0。
- 输入nan,返回0。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = 0.0, x2 = -0.0, x3 = 1.5, x4 = -2.5; // special handing double a = INFINITY, b = -INFINITY, c = NAN; // print result printf("finite(0.0) = %d\n", finite(x1)); printf("finite(-0.0) = %d\n", finite(x2)); printf("finite(1.5) = %d\n", finite(x3)); printf("finite(-2.5) = %d\n", finite(x4)); printf("finite(INFINITY) = %d\n", finite(a)); printf("finite(-INFINITY) = %d\n", finite(b)); printf("finite(NAN) = %d\n", finite(c)); /* * finite(0.0) = 1 * finite(-0.0) = 1 * finite(1.5) = 1 * finite(-2.5) = 1 * finite(INFINITY) = 0 * finite(-INFINITY) = 0 * finite(NAN) = 0 * * */
父主题: 杂项函数