将x转换为归一化[1/2, 1)的有符号数乘以2的积分幂。返回归一化的有符号数,指数存储在exp中。
C interface:
float frexpf(float x, int *exp);
double frexp(double x, int *exp);
long double frexpl(long double x, int *exp);
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
exp |
exp是整数类型指针。 |
指数。 |
输出 |
C: "km.h"
// print result int32_t exp; printf("frexp(3.4, &exp) = %.15f, exp = %d\n", frexp(3.4, &exp), exp); printf("frexp(-4.8, &exp) = %.15f, exp = %d\n", frexp(-4.8, &exp), exp); printf("frexp(NAN, &exp) = %.15f, exp = %d\n", frexp(NAN, &exp), exp); printf("frexp(-NAN, &exp) = %.15f, exp = %d\n", frexp(-NAN, &exp), exp); printf("frexp(INFINITY, &exp) = %.15f, exp = %d\n", frexp(INFINITY, &exp), exp); printf("frexp(-INFINITY, &exp) = %.15f, exp = %d\n", frexp(-INFINITY, &exp), exp); result /* * frexp(3.4, &exp) = 0.850000000000000, exp = 2 * frexp(-4.8, &exp) = -0.600000000000000, exp = 3 * frexp(NAN, &exp) = nan, exp = 3 * frexp(-NAN, &exp) = -nan, exp = 3 * frexp(INFINITY, &exp) = inf, exp = 3 * frexp(-INFINITY, &exp) = -inf, exp = 3 * */