Commit | Line | Data |
5d7098d5 |
1 | #!./perl |
2 | |
88587957 |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | |
5d7098d5 |
8 | require "bigfloat.pl"; |
9 | |
10 | $test = 0; |
11 | $| = 1; |
12 | print "1..355\n"; |
13 | while (<DATA>) { |
14 | chop; |
15 | if (/^&/) { |
16 | $f = $_; |
17 | } elsif (/^\$.*/) { |
18 | eval "$_;"; |
19 | } else { |
20 | ++$test; |
21 | @args = split(/:/,$_,99); |
22 | $ans = pop(@args); |
23 | $try = "$f('" . join("','", @args) . "');"; |
24 | if (($ans1 = eval($try)) eq $ans) { |
25 | print "ok $test\n"; |
26 | } else { |
27 | print "not ok $test\n"; |
28 | print "# '$try' expected: '$ans' got: '$ans1'\n"; |
29 | } |
30 | } |
31 | } |
32 | __END__ |
33 | &fnorm |
34 | abc:NaN |
35 | 1 a:NaN |
36 | 1bcd2:NaN |
37 | 11111b:NaN |
38 | +1z:NaN |
39 | -1z:NaN |
40 | 0:+0E+0 |
41 | +0:+0E+0 |
42 | +00:+0E+0 |
43 | +0 0 0:+0E+0 |
44 | 000000 0000000 00000:+0E+0 |
45 | -0:+0E+0 |
46 | -0000:+0E+0 |
47 | +1:+1E+0 |
48 | +01:+1E+0 |
49 | +001:+1E+0 |
50 | +00000100000:+1E+5 |
51 | 123456789:+123456789E+0 |
52 | -1:-1E+0 |
53 | -01:-1E+0 |
54 | -001:-1E+0 |
55 | -123456789:-123456789E+0 |
56 | -00000100000:-1E+5 |
57 | 123.456a:NaN |
58 | 123.456:+123456E-3 |
59 | 0.01:+1E-2 |
60 | .002:+2E-3 |
61 | -0.0003:-3E-4 |
62 | -.0000000004:-4E-10 |
63 | 123456E2:+123456E+2 |
64 | 123456E-2:+123456E-2 |
65 | -123456E2:-123456E+2 |
66 | -123456E-2:-123456E-2 |
67 | 1e1:+1E+1 |
68 | 2e-11:+2E-11 |
69 | -3e111:-3E+111 |
70 | -4e-1111:-4E-1111 |
71 | &fneg |
72 | abd:NaN |
73 | +0:+0E+0 |
74 | +1:-1E+0 |
75 | -1:+1E+0 |
76 | +123456789:-123456789E+0 |
77 | -123456789:+123456789E+0 |
78 | +123.456789:-123456789E-6 |
79 | -123456.789:+123456789E-3 |
80 | &fabs |
81 | abc:NaN |
82 | +0:+0E+0 |
83 | +1:+1E+0 |
84 | -1:+1E+0 |
85 | +123456789:+123456789E+0 |
86 | -123456789:+123456789E+0 |
87 | +123.456789:+123456789E-6 |
88 | -123456.789:+123456789E-3 |
89 | &fround |
90 | $bigfloat::rnd_mode = 'trunc' |
91 | +10123456789:5:+10123E+6 |
92 | -10123456789:5:-10123E+6 |
93 | +10123456789:9:+101234567E+2 |
94 | -10123456789:9:-101234567E+2 |
95 | +101234500:6:+101234E+3 |
96 | -101234500:6:-101234E+3 |
97 | $bigfloat::rnd_mode = 'zero' |
98 | +20123456789:5:+20123E+6 |
99 | -20123456789:5:-20123E+6 |
100 | +20123456789:9:+201234568E+2 |
101 | -20123456789:9:-201234568E+2 |
102 | +201234500:6:+201234E+3 |
103 | -201234500:6:-201234E+3 |
104 | $bigfloat::rnd_mode = '+inf' |
105 | +30123456789:5:+30123E+6 |
106 | -30123456789:5:-30123E+6 |
107 | +30123456789:9:+301234568E+2 |
108 | -30123456789:9:-301234568E+2 |
109 | +301234500:6:+301235E+3 |
110 | -301234500:6:-301234E+3 |
111 | $bigfloat::rnd_mode = '-inf' |
112 | +40123456789:5:+40123E+6 |
113 | -40123456789:5:-40123E+6 |
114 | +40123456789:9:+401234568E+2 |
115 | -40123456789:9:-401234568E+2 |
116 | +401234500:6:+401234E+3 |
117 | -401234500:6:-401235E+3 |
118 | $bigfloat::rnd_mode = 'odd' |
119 | +50123456789:5:+50123E+6 |
120 | -50123456789:5:-50123E+6 |
121 | +50123456789:9:+501234568E+2 |
122 | -50123456789:9:-501234568E+2 |
123 | +501234500:6:+501235E+3 |
124 | -501234500:6:-501235E+3 |
125 | $bigfloat::rnd_mode = 'even' |
126 | +60123456789:5:+60123E+6 |
127 | -60123456789:5:-60123E+6 |
128 | +60123456789:9:+601234568E+2 |
129 | -60123456789:9:-601234568E+2 |
130 | +601234500:6:+601234E+3 |
131 | -601234500:6:-601234E+3 |
132 | &ffround |
133 | $bigfloat::rnd_mode = 'trunc' |
134 | +1.23:-1:+12E-1 |
135 | -1.23:-1:-12E-1 |
136 | +1.27:-1:+12E-1 |
137 | -1.27:-1:-12E-1 |
138 | +1.25:-1:+12E-1 |
139 | -1.25:-1:-12E-1 |
140 | +1.35:-1:+13E-1 |
141 | -1.35:-1:-13E-1 |
142 | -0.006:-1:+0E+0 |
143 | -0.006:-2:+0E+0 |
144 | $bigfloat::rnd_mode = 'zero' |
145 | +2.23:-1:+22E-1 |
146 | -2.23:-1:-22E-1 |
147 | +2.27:-1:+23E-1 |
148 | -2.27:-1:-23E-1 |
149 | +2.25:-1:+22E-1 |
150 | -2.25:-1:-22E-1 |
151 | +2.35:-1:+23E-1 |
152 | -2.35:-1:-23E-1 |
153 | -0.0065:-1:+0E+0 |
154 | -0.0065:-2:-1E-2 |
155 | -0.0065:-3:-6E-3 |
156 | -0.0065:-4:-65E-4 |
157 | -0.0065:-5:-65E-4 |
158 | $bigfloat::rnd_mode = '+inf' |
159 | +3.23:-1:+32E-1 |
160 | -3.23:-1:-32E-1 |
161 | +3.27:-1:+33E-1 |
162 | -3.27:-1:-33E-1 |
163 | +3.25:-1:+33E-1 |
164 | -3.25:-1:-32E-1 |
165 | +3.35:-1:+34E-1 |
166 | -3.35:-1:-33E-1 |
167 | -0.0065:-1:+0E+0 |
168 | -0.0065:-2:-1E-2 |
169 | -0.0065:-3:-6E-3 |
170 | -0.0065:-4:-65E-4 |
171 | -0.0065:-5:-65E-4 |
172 | $bigfloat::rnd_mode = '-inf' |
173 | +4.23:-1:+42E-1 |
174 | -4.23:-1:-42E-1 |
175 | +4.27:-1:+43E-1 |
176 | -4.27:-1:-43E-1 |
177 | +4.25:-1:+42E-1 |
178 | -4.25:-1:-43E-1 |
179 | +4.35:-1:+43E-1 |
180 | -4.35:-1:-44E-1 |
181 | -0.0065:-1:+0E+0 |
182 | -0.0065:-2:-1E-2 |
183 | -0.0065:-3:-7E-3 |
184 | -0.0065:-4:-65E-4 |
185 | -0.0065:-5:-65E-4 |
186 | $bigfloat::rnd_mode = 'odd' |
187 | +5.23:-1:+52E-1 |
188 | -5.23:-1:-52E-1 |
189 | +5.27:-1:+53E-1 |
190 | -5.27:-1:-53E-1 |
191 | +5.25:-1:+53E-1 |
192 | -5.25:-1:-53E-1 |
193 | +5.35:-1:+53E-1 |
194 | -5.35:-1:-53E-1 |
195 | -0.0065:-1:+0E+0 |
196 | -0.0065:-2:-1E-2 |
197 | -0.0065:-3:-7E-3 |
198 | -0.0065:-4:-65E-4 |
199 | -0.0065:-5:-65E-4 |
200 | $bigfloat::rnd_mode = 'even' |
201 | +6.23:-1:+62E-1 |
202 | -6.23:-1:-62E-1 |
203 | +6.27:-1:+63E-1 |
204 | -6.27:-1:-63E-1 |
205 | +6.25:-1:+62E-1 |
206 | -6.25:-1:-62E-1 |
207 | +6.35:-1:+64E-1 |
208 | -6.35:-1:-64E-1 |
209 | -0.0065:-1:+0E+0 |
210 | -0.0065:-2:-1E-2 |
211 | -0.0065:-3:-6E-3 |
212 | -0.0065:-4:-65E-4 |
213 | -0.0065:-5:-65E-4 |
214 | &fcmp |
215 | abc:abc: |
216 | abc:+0: |
217 | +0:abc: |
218 | +0:+0:0 |
219 | -1:+0:-1 |
220 | +0:-1:1 |
221 | +1:+0:1 |
222 | +0:+1:-1 |
223 | -1:+1:-1 |
224 | +1:-1:1 |
225 | -1:-1:0 |
226 | +1:+1:0 |
227 | +123:+123:0 |
228 | +123:+12:1 |
229 | +12:+123:-1 |
230 | -123:-123:0 |
231 | -123:-12:-1 |
232 | -12:-123:1 |
233 | +123:+124:-1 |
234 | +124:+123:1 |
235 | -123:-124:1 |
236 | -124:-123:-1 |
237 | &fadd |
238 | abc:abc:NaN |
239 | abc:+0:NaN |
240 | +0:abc:NaN |
241 | +0:+0:+0E+0 |
242 | +1:+0:+1E+0 |
243 | +0:+1:+1E+0 |
244 | +1:+1:+2E+0 |
245 | -1:+0:-1E+0 |
246 | +0:-1:-1E+0 |
247 | -1:-1:-2E+0 |
248 | -1:+1:+0E+0 |
249 | +1:-1:+0E+0 |
250 | +9:+1:+1E+1 |
251 | +99:+1:+1E+2 |
252 | +999:+1:+1E+3 |
253 | +9999:+1:+1E+4 |
254 | +99999:+1:+1E+5 |
255 | +999999:+1:+1E+6 |
256 | +9999999:+1:+1E+7 |
257 | +99999999:+1:+1E+8 |
258 | +999999999:+1:+1E+9 |
259 | +9999999999:+1:+1E+10 |
260 | +99999999999:+1:+1E+11 |
261 | +10:-1:+9E+0 |
262 | +100:-1:+99E+0 |
263 | +1000:-1:+999E+0 |
264 | +10000:-1:+9999E+0 |
265 | +100000:-1:+99999E+0 |
266 | +1000000:-1:+999999E+0 |
267 | +10000000:-1:+9999999E+0 |
268 | +100000000:-1:+99999999E+0 |
269 | +1000000000:-1:+999999999E+0 |
270 | +10000000000:-1:+9999999999E+0 |
271 | +123456789:+987654321:+111111111E+1 |
272 | -123456789:+987654321:+864197532E+0 |
273 | -123456789:-987654321:-111111111E+1 |
274 | +123456789:-987654321:-864197532E+0 |
275 | &fsub |
276 | abc:abc:NaN |
277 | abc:+0:NaN |
278 | +0:abc:NaN |
279 | +0:+0:+0E+0 |
280 | +1:+0:+1E+0 |
281 | +0:+1:-1E+0 |
282 | +1:+1:+0E+0 |
283 | -1:+0:-1E+0 |
284 | +0:-1:+1E+0 |
285 | -1:-1:+0E+0 |
286 | -1:+1:-2E+0 |
287 | +1:-1:+2E+0 |
288 | +9:+1:+8E+0 |
289 | +99:+1:+98E+0 |
290 | +999:+1:+998E+0 |
291 | +9999:+1:+9998E+0 |
292 | +99999:+1:+99998E+0 |
293 | +999999:+1:+999998E+0 |
294 | +9999999:+1:+9999998E+0 |
295 | +99999999:+1:+99999998E+0 |
296 | +999999999:+1:+999999998E+0 |
297 | +9999999999:+1:+9999999998E+0 |
298 | +99999999999:+1:+99999999998E+0 |
299 | +10:-1:+11E+0 |
300 | +100:-1:+101E+0 |
301 | +1000:-1:+1001E+0 |
302 | +10000:-1:+10001E+0 |
303 | +100000:-1:+100001E+0 |
304 | +1000000:-1:+1000001E+0 |
305 | +10000000:-1:+10000001E+0 |
306 | +100000000:-1:+100000001E+0 |
307 | +1000000000:-1:+1000000001E+0 |
308 | +10000000000:-1:+10000000001E+0 |
309 | +123456789:+987654321:-864197532E+0 |
310 | -123456789:+987654321:-111111111E+1 |
311 | -123456789:-987654321:+864197532E+0 |
312 | +123456789:-987654321:+111111111E+1 |
313 | &fmul |
314 | abc:abc:NaN |
315 | abc:+0:NaN |
316 | +0:abc:NaN |
317 | +0:+0:+0E+0 |
318 | +0:+1:+0E+0 |
319 | +1:+0:+0E+0 |
320 | +0:-1:+0E+0 |
321 | -1:+0:+0E+0 |
322 | +123456789123456789:+0:+0E+0 |
323 | +0:+123456789123456789:+0E+0 |
324 | -1:-1:+1E+0 |
325 | -1:+1:-1E+0 |
326 | +1:-1:-1E+0 |
327 | +1:+1:+1E+0 |
328 | +2:+3:+6E+0 |
329 | -2:+3:-6E+0 |
330 | +2:-3:-6E+0 |
331 | -2:-3:+6E+0 |
332 | +111:+111:+12321E+0 |
333 | +10101:+10101:+102030201E+0 |
334 | +1001001:+1001001:+1002003002001E+0 |
335 | +100010001:+100010001:+10002000300020001E+0 |
336 | +10000100001:+10000100001:+100002000030000200001E+0 |
337 | +11111111111:+9:+99999999999E+0 |
338 | +22222222222:+9:+199999999998E+0 |
339 | +33333333333:+9:+299999999997E+0 |
340 | +44444444444:+9:+399999999996E+0 |
341 | +55555555555:+9:+499999999995E+0 |
342 | +66666666666:+9:+599999999994E+0 |
343 | +77777777777:+9:+699999999993E+0 |
344 | +88888888888:+9:+799999999992E+0 |
345 | +99999999999:+9:+899999999991E+0 |
346 | &fdiv |
347 | abc:abc:NaN |
348 | abc:+1:abc:NaN |
349 | +1:abc:NaN |
350 | +0:+0:NaN |
351 | +0:+1:+0E+0 |
352 | +1:+0:NaN |
353 | +0:-1:+0E+0 |
354 | -1:+0:NaN |
355 | +1:+1:+1E+0 |
356 | -1:-1:+1E+0 |
357 | +1:-1:-1E+0 |
358 | -1:+1:-1E+0 |
359 | +1:+2:+5E-1 |
360 | +2:+1:+2E+0 |
361 | +10:+5:+2E+0 |
362 | +100:+4:+25E+0 |
363 | +1000:+8:+125E+0 |
364 | +10000:+16:+625E+0 |
365 | +10000:-16:-625E+0 |
366 | +999999999999:+9:+111111111111E+0 |
367 | +999999999999:+99:+10101010101E+0 |
368 | +999999999999:+999:+1001001001E+0 |
369 | +999999999999:+9999:+100010001E+0 |
370 | +999999999999999:+99999:+10000100001E+0 |
371 | +1000000000:+9:+1111111111111111111111111111111111111111E-31 |
372 | +2000000000:+9:+2222222222222222222222222222222222222222E-31 |
373 | +3000000000:+9:+3333333333333333333333333333333333333333E-31 |
374 | +4000000000:+9:+4444444444444444444444444444444444444444E-31 |
375 | +5000000000:+9:+5555555555555555555555555555555555555556E-31 |
376 | +6000000000:+9:+6666666666666666666666666666666666666667E-31 |
377 | +7000000000:+9:+7777777777777777777777777777777777777778E-31 |
378 | +8000000000:+9:+8888888888888888888888888888888888888889E-31 |
379 | +9000000000:+9:+1E+9 |
380 | +35500000:+113:+3141592920353982300884955752212389380531E-34 |
381 | +71000000:+226:+3141592920353982300884955752212389380531E-34 |
382 | +106500000:+339:+3141592920353982300884955752212389380531E-34 |
383 | +1000000000:+3:+3333333333333333333333333333333333333333E-31 |
384 | $bigfloat::div_scale = 20 |
385 | +1000000000:+9:+11111111111111111111E-11 |
386 | +2000000000:+9:+22222222222222222222E-11 |
387 | +3000000000:+9:+33333333333333333333E-11 |
388 | +4000000000:+9:+44444444444444444444E-11 |
389 | +5000000000:+9:+55555555555555555556E-11 |
390 | +6000000000:+9:+66666666666666666667E-11 |
391 | +7000000000:+9:+77777777777777777778E-11 |
392 | +8000000000:+9:+88888888888888888889E-11 |
393 | +9000000000:+9:+1E+9 |
394 | +35500000:+113:+314159292035398230088E-15 |
395 | +71000000:+226:+314159292035398230088E-15 |
396 | +106500000:+339:+31415929203539823009E-14 |
397 | +1000000000:+3:+33333333333333333333E-11 |
398 | $bigfloat::div_scale = 40 |
399 | &fsqrt |
400 | +0:+0E+0 |
401 | -1:NaN |
402 | -2:NaN |
403 | -16:NaN |
404 | -123.456:NaN |
405 | +1:+1E+0 |
406 | +1.44:+12E-1 |
407 | +2:+141421356237309504880168872420969807857E-38 |
408 | +4:+2E+0 |
409 | +16:+4E+0 |
410 | +100:+1E+1 |
411 | +123.456:+1111107555549866648462149404118219234119E-38 |
412 | +15241.383936:+123456E-3 |