c语言L文件,frexpl - [ C语言中文开发手册 ] - 在线原生手册 - php中文网

在头文件中定义float frexpf(float arg,int * exp);(1)(自C99以来)

double frexp(double arg,int * exp);(2)

long double frexpl(long double arg,int * exp);(3)(自C99以来)

在头文件中定义

#define frexp(arg,exp)(4)(自C99以来)

1-3)将给定浮点值x分解为归一化分数和2的整数幂。

4)类型 - 通用宏:如果arg的类型为long double,则调用frexpl。 否则,如果arg具有整数类型或类型double,则调用frexp。 否则,分别调用frexpf。

参数

ARG-浮点值EXP-指向整数值以存储指数的指针

函数frexp及其双重ldexp可用于操纵浮点数的表示,而无需直接位操作。

否则(如果arg不为零),如果没有发生错误,则返回范围(-1; -0.5],[0.5; 1)中的值x并将* exp中的整数值存储为x×2(* exp)

#include #include #include 

int main(void){

double f = 123.45;    printf("Given the number %.2f or %a in hex,\n", f, f);

double f3;

double f2 = modf(f, &f3);    printf("modf() makes %.0f + %.2f\n", f3, f2);

int i;

f2 = frexp(f, &i);    printf("frexp() makes %f * 2^%d\n", f2, i);

i = ilogb(f);    printf("logb()/ilogb() make %f * %d^%d\n", f/scalbn(1.0, i), FLT_RADIX, i);}

如果要存储在* exp中的值超出int范围,则行为未指定。

可能的输出:

错误处理

Given the number 123.45 or 0x1.edccccccccccdp+6 in hex,modf() makes 123 + 0.45frexp() makes 0.964453 * 2^7logb()/ilogb() make 1.92891 * 2^6

如果实现支持IEEE浮点运算(IEC 60559),

参考

C11标准(ISO / IEC 9899:2011):7.12.6.4 frexp函数(p:243)

7.25类型通用数学(p:373-375)

F.10.3.4 frexp函数(p:521)

C99标准(ISO / IEC 9899:1999):7.12.6.4 frexp函数(p:224)

7.22类型通用数学(p:335-337)

F.9.3.4 frexp函数(p:458)

C89 / C90标准(ISO / IEC 9899:1990):4.5.4.2 frexp函数

扩展内容

| 用于frexp的C ++文档 |

函数frexp及其双重ldexp可用于操纵浮点数的表示,而无需直接位操作。

#include #include #include 

int main(void){

double f = 123.45;    printf("Given the number %.2f or %a in hex,\n", f, f);

double f3;

double f2 = modf(f, &f3);    printf("modf() makes %.0f + %.2f\n", f3, f2);

int i;

f2 = frexp(f, &i);    printf("frexp() makes %f * 2^%d\n", f2, i);

i = ilogb(f);    printf("logb()/ilogb() make %f * %d^%d\n", f/scalbn(1.0, i), FLT_RADIX, i);}

可能的输出:

Given the number 123.45 or 0x1.edccccccccccdp+6 in hex,modf() makes 123 + 0.45frexp() makes 0.964453 * 2^7logb()/ilogb() make 1.92891 * 2^6

参考

C11标准(ISO / IEC 9899:2011):7.12.6.4 frexp函数(p:243)

7.25类型通用数学(p:373-375)

F.10.3.4 frexp函数(p:521)

C99标准(ISO / IEC 9899:1999):7.12.6.4 frexp函数(p:224)

7.22类型通用数学(p:335-337)

F.9.3.4 frexp函数(p:458)

C89 / C90标准(ISO / IEC 9899:1990):4.5.4.2 frexp函数

扩展内容

ldexpldexpfldexpl(C99)(C99)将一个数字乘以2来提高权力(功能)logblogbflogbl(C99)(C99)(C99)提取给定数字的指数(函数)

ilogbilogbfilogbl(C99)(C99)(C99)提取给定数字的指数(函数)

modfmodffmodfl(C99)(C99)将数字分成整数和小数部分(函数)

| 用于frexp的C ++文档 |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值