Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6536 | serge | 1 | /* |
2 | FUNCTION |
||
3 | < |
||
4 | |||
5 | INDEX |
||
6 | ecvt |
||
7 | INDEX |
||
8 | ecvtf |
||
9 | INDEX |
||
10 | fcvt |
||
11 | INDEX |
||
12 | fcvtf |
||
13 | |||
14 | ANSI_SYNOPSIS |
||
15 | #include |
||
16 | |||
17 | char *ecvt(double <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>); |
||
18 | char *ecvtf(float <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>); |
||
19 | |||
20 | char *fcvt(double <[val]>, int <[decimals]>, |
||
21 | int *<[decpt]>, int *<[sgn]>); |
||
22 | char *fcvtf(float <[val]>, int <[decimals]>, |
||
23 | int *<[decpt]>, int *<[sgn]>); |
||
24 | |||
25 | TRAD_SYNOPSIS |
||
26 | #include |
||
27 | |||
28 | char *ecvt(<[val]>, <[chars]>, <[decpt]>, <[sgn]>); |
||
29 | double <[val]>; |
||
30 | int <[chars]>; |
||
31 | int *<[decpt]>; |
||
32 | int *<[sgn]>; |
||
33 | char *ecvtf(<[val]>, <[chars]>, <[decpt]>, <[sgn]>); |
||
34 | float <[val]>; |
||
35 | int <[chars]>; |
||
36 | int *<[decpt]>; |
||
37 | int *<[sgn]>; |
||
38 | |||
39 | char *fcvt(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>); |
||
40 | double <[val]>; |
||
41 | int <[decimals]>; |
||
42 | int *<[decpt]>; |
||
43 | int *<[sgn]>; |
||
44 | char *fcvtf(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>); |
||
45 | float <[val]>; |
||
46 | int <[decimals]>; |
||
47 | int *<[decpt]>; |
||
48 | int *<[sgn]>; |
||
49 | |||
50 | DESCRIPTION |
||
51 | < |
||
52 | representating the < |
||
53 | < |
||
54 | representations of < |
||
55 | |||
56 | (The < |
||
57 | versions of < |
||
58 | |||
59 | The only difference between < |
||
60 | interpretation of the second argument (<[chars]> or <[decimals]>). |
||
61 | For < |
||
62 | of characters to write (which is also the number of significant digits |
||
63 | in the formatted string, since these two functions write only digits). |
||
64 | For < |
||
65 | characters to write after the decimal point; all digits for the integer |
||
66 | part of <[val]> are always included. |
||
67 | |||
68 | Since < |
||
69 | they record the location of the decimal point in <<*<[decpt]>>>, and |
||
70 | the sign of the number in <<*<[sgn]>>>. After formatting a number, |
||
71 | <<*<[decpt]>>> contains the number of digits to the left of the |
||
72 | decimal point. <<*<[sgn]>>> contains <<0>> if the number is positive, |
||
73 | and <<1>> if it is negative. |
||
74 | |||
75 | RETURNS |
||
76 | All four functions return a pointer to the new string containing a |
||
77 | character representation of <[val]>. |
||
78 | |||
79 | PORTABILITY |
||
80 | None of these functions are ANSI C. |
||
81 | |||
82 | Supporting OS subroutines required: < |
||
83 | < |
||
84 | |||
85 | NEWPAGE |
||
86 | FUNCTION |
||
87 | < |
||
88 | |||
89 | INDEX |
||
90 | gcvt |
||
91 | INDEX |
||
92 | gcvtf |
||
93 | |||
94 | ANSI_SYNOPSIS |
||
95 | #include |
||
96 | |||
97 | char *gcvt(double <[val]>, int <[precision]>, char *<[buf]>); |
||
98 | char *gcvtf(float <[val]>, int <[precision]>, char *<[buf]>); |
||
99 | |||
100 | TRAD_SYNOPSIS |
||
101 | #include |
||
102 | |||
103 | char *gcvt(<[val]>, <[precision]>, <[buf]>); |
||
104 | double <[val]>; |
||
105 | int <[precision]>; |
||
106 | char *<[buf]>; |
||
107 | char *gcvtf(<[val]>, <[precision]>, <[buf]>); |
||
108 | float <[val]>; |
||
109 | int <[precision]>; |
||
110 | char *<[buf]>; |
||
111 | |||
112 | DESCRIPTION |
||
113 | < |
||
114 | string in the buffer <<*<[buf]>>>. < |
||
115 | character representations of < |
||
116 | |||
117 | < |
||
118 | `<<%.<[precision]>g>>'---only negative values are signed (with |
||
119 | `<<->>'), and either exponential or ordinary decimal-fraction format |
||
120 | is chosen depending on the number of significant digits (specified by |
||
121 | <[precision]>). |
||
122 | |||
123 | RETURNS |
||
124 | The result is a pointer to the formatted representation of <[val]> |
||
125 | (the same as the argument <[buf]>). |
||
126 | |||
127 | PORTABILITY |
||
128 | Neither function is ANSI C. |
||
129 | |||
130 | Supporting OS subroutines required: < |
||
131 | < |
||
132 | */ |
||
133 | |||
134 | #define _XOPEN_SOURCE |
||
135 | #define _XOPEN_SOURCE_EXTENDED |
||
136 | #include <_ansi.h> |
||
137 | #include |
||
138 | #include |
||
139 | #include |
||
140 | #include "local.h" |
||
141 | |||
142 | char * |
||
143 | _DEFUN (fcvt, (d, ndigit, decpt, sign), |
||
144 | double d _AND |
||
145 | int ndigit _AND |
||
146 | int *decpt _AND |
||
147 | int *sign) |
||
148 | { |
||
149 | return fcvtbuf (d, ndigit, decpt, sign, NULL); |
||
150 | } |
||
151 | |||
152 | char * |
||
153 | _DEFUN (fcvtf, (d, ndigit, decpt, sign), |
||
154 | float d _AND |
||
155 | int ndigit _AND |
||
156 | int *decpt _AND |
||
157 | int *sign) |
||
158 | { |
||
159 | return fcvt ((float) d, ndigit, decpt, sign); |
||
160 | } |
||
161 | |||
162 | |||
163 | char * |
||
164 | _DEFUN (gcvtf, (d, ndigit, buf), |
||
165 | float d _AND |
||
166 | int ndigit _AND |
||
167 | char *buf) |
||
168 | { |
||
169 | double asd = d; |
||
170 | return gcvt (asd, ndigit, buf); |
||
171 | } |
||
172 | |||
173 | |||
174 | char * |
||
175 | _DEFUN (ecvt, (d, ndigit, decpt, sign), |
||
176 | double d _AND |
||
177 | int ndigit _AND |
||
178 | int *decpt _AND |
||
179 | int *sign) |
||
180 | { |
||
181 | return ecvtbuf (d, ndigit, decpt, sign, NULL); |
||
182 | } |
||
183 | |||
184 | char * |
||
185 | _DEFUN (ecvtf, (d, ndigit, decpt, sign), |
||
186 | float d _AND |
||
187 | int ndigit _AND |
||
188 | int *decpt _AND |
||
189 | int *sign) |
||
190 | { |
||
191 | return ecvt ((double) d, ndigit, decpt, sign); |
||
192 | } |
||
193 | |||
194 | |||
195 | char * |
||
196 | _DEFUN (gcvt, (d, ndigit, buf), |
||
197 | double d _AND |
||
198 | int ndigit _AND |
||
199 | char *buf) |
||
200 | { |
||
201 | char *tbuf = buf; |
||
202 | if (d < 0) { |
||
203 | *buf = '-'; |
||
204 | buf++; |
||
205 | ndigit--; |
||
206 | } |
||
207 | return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0); |
||
208 | }> |