ilogb
计算x的指数,返回整形结果。
接口定义
C interface:
int ilogbf(float x);
int ilogb(double x);
int ilogbl(long double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 输入x为±∞,返回INT_MAX。
- 输入x为±0,返回INT_MIN。
- 输入x为nan,返回INT_MAX。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = 0.0, x2 = -0.0, x3 = 0x1p-1074, x4 = 0x1p1024; float x5 = 0x1p-149f; // special handing double a = INFINITY, b = -INFINITY, c = NAN; // print result printf("ilogb(0.0) = %d\n", ilogb(x1)); printf("ilogb(-0.0) = %d\n", ilogb(x2)); printf("ilogb(0x1p-1074) = %d\n", ilogb(x3)); printf("ilogb(0x1p1024) = %d\n", ilogb(x4)); printf("ilogbf(0x1p-150) = %d\n", ilogbf(x5)); printf("ilogb(INFINITY) = %d\n", ilogb(a)); printf("ilogb(-INFINITY) = %d\n", ilogb(b)); printf("ilogb(NAN) = %d\n", ilogb(c)); /* * ilogb(0.0) = -inf * ilogb(-0.0) = -inf * ilogb(0x1p-1074) = -1074.000000000000000 * ilogb(0x1p1024) = inf * ilogbf(0x1p-150) = -149.000000000000000 * ilogb(INFINITY) = inf * ilogb(-INFINITY) = inf * ilogb(NAN) = nan * * */
父主题: 指数和对数函数