|
|
1.1 root 1:
2:
3: frexp() General Function frexp()
4:
5:
6:
7:
8: Separate fraction and exponent
9:
10: ddoouubbllee ffrreexxpp(_r_e_a_l, _e_p) ddoouubbllee _r_e_a_l; iinntt *_e_p;
11:
12: frexp breaks double-precision floating point numbers into frac-
13: tion and exponent. It returns the fraction m of its real argu-
14: ment, such that 0.5 <= _m < 1 or _m=0, and stores the binary ex-
15: ponent e in the location pointed to by ep. These numbers satisfy
16: the equation _r_e_a_l = _m * 2^_e.
17:
18: ***** Example *****
19:
20: This example prompts for a number, then uses frexp to break it
21: into its fraction and exponent.
22:
23:
24: #include <stdio.h>
25:
26:
27:
28: main()
29: {
30: extern char *gets();
31: extern double frexp(), atof();
32: double real, fraction;
33: int ep;
34:
35:
36:
37: char string[64];
38:
39:
40:
41: for (;;) {
42: printf("Enter number: ");
43: if (gets(string) == NULL)
44: break;
45:
46:
47:
48:
49: fraction = frexp(real, &ep);
50: printf("%lf is the fraction of %lf\n",
51: fraction, real);
52: printf("%d is the binary exponent of %lf\n",
53: ep, real);
54: }
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: frexp() General Function frexp()
70:
71:
72:
73: putchar('\n');
74: }
75:
76:
77: ***** See Also *****
78:
79: atof(), ceil(), fabs(), floor(), general functions, ldexp(),
80: modf()
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.