?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
在頭文件<math.h>中定義 | ||
---|---|---|
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以來) |
在頭文件<tgmath.h>中定義 | ||
#define frexp(arg,exp) | (4) | (自C99以來) |
1-3)將給定浮點值x分解為歸一化分數(shù)和2的整數(shù)冪。
4)類型 - 通用宏:如果arg的類型為long double,則調用frexpl。 否則,如果arg具有整數(shù)類型或類型double,則調用frexp。 否則,分別調用frexpf。
ARG | - | 浮點值 |
---|---|---|
EXP | - | 指向整數(shù)值以存儲指數(shù)的指針 |
函數(shù)frexp及其雙重ldexp可用于操縱浮點數(shù)的表示,而無需直接位操作。
否則(如果arg不為零),如果沒有發(fā)生錯誤,則返回范圍(-1; -0.5],[0.5; 1)中的值x并將* exp中的整數(shù)值存儲為x×2(* exp)
#include <stdio.h>#include <math.h>#include <float.h> 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
如果實現(xiàn)支持IEEE浮點運算(IEC 60559),
C11標準(ISO / IEC 9899:2011):
7.12.6.4 frexp函數(shù)(p:243)
7.25類型通用數(shù)學<tgmath.h>(p:373-375)
F.10.3.4 frexp函數(shù)(p:521)
C99標準(ISO / IEC 9899:1999):
7.12.6.4 frexp函數(shù)(p:224)
7.22類型通用數(shù)學<tgmath.h>(p:335-337)
F.9.3.4 frexp函數(shù)(p:458)
C89 / C90標準(ISO / IEC 9899:1990):
4.5.4.2 frexp函數(shù)
| 用于frexp的C ++文檔 |
函數(shù)frexp及其雙重ldexp可用于操縱浮點數(shù)的表示,而無需直接位操作。
#include <stdio.h>#include <math.h>#include <float.h> 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函數(shù)(p:243)
7.25類型通用數(shù)學<tgmath.h>(p:373-375)
F.10.3.4 frexp函數(shù)(p:521)
C99標準(ISO / IEC 9899:1999):
7.12.6.4 frexp函數(shù)(p:224)
7.22類型通用數(shù)學<tgmath.h>(p:335-337)
F.9.3.4 frexp函數(shù)(p:458)
C89 / C90標準(ISO / IEC 9899:1990):
4.5.4.2 frexp函數(shù)
ldexpldexpfldexpl(C99)(C99) | 將一個數(shù)字乘以2來提高權力(功能) |
---|---|
logblogbflogbl(C99)(C99)(C99) | 提取給定數(shù)字的指數(shù)(函數(shù)) |
ilogbilogbfilogbl(C99)(C99)(C99) | 提取給定數(shù)字的指數(shù)(函數(shù)) |
modfmodffmodfl(C99)(C99) | 將數(shù)字分成整數(shù)和小數(shù)部分(函數(shù)) |
| 用于frexp的C ++文檔 |