Commit | Line | Data |
ee15d750 |
1 | #include this file into another test for subclass testing... |
2 | while (<DATA>) |
3 | { |
4 | chop; |
5 | $_ =~ s/#.*$//; # remove comments |
6 | $_ =~ s/\s+$//; # trailing spaces |
7 | next if /^$/; # skip empty lines & comments |
8 | if (s/^&//) |
9 | { |
10 | $f = $_; |
11 | } |
12 | elsif (/^\$/) |
13 | { |
14 | $setup = $_; $setup =~ s/\$/\$${class}::/g; # round_mode, div_scale |
15 | #print "\$setup== $setup\n"; |
16 | } |
17 | else |
18 | { |
19 | if (m|^(.*?):(/.+)$|) |
20 | { |
21 | $ans = $2; |
22 | @args = split(/:/,$1,99); |
23 | } |
24 | else |
25 | { |
26 | @args = split(/:/,$_,99); $ans = pop(@args); |
27 | } |
28 | $try = "\$x = new $class \"$args[0]\";"; |
29 | if ($f eq "fnorm") |
30 | { |
31 | $try .= "\$x;"; |
32 | } elsif ($f eq "finf") { |
33 | $try .= "\$x->finf('$args[1]');"; |
027dc388 |
34 | } elsif ($f eq "is_inf") { |
35 | $try .= "\$x->is_inf('$args[1]');"; |
ee15d750 |
36 | } elsif ($f eq "fone") { |
37 | $try .= "\$x->bone('$args[1]');"; |
38 | } elsif ($f eq "fstr") { |
39 | $try .= "\$x->accuracy($args[1]); \$x->precision($args[2]);"; |
40 | $try .= '$x->fstr();'; |
ee15d750 |
41 | } elsif ($f eq "parts") { |
48b581a2 |
42 | # ->bstr() to see if an object is returned |
ee15d750 |
43 | $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();'; |
44 | $try .= '"$a $b";'; |
ee15d750 |
45 | } elsif ($f eq "exponent") { |
48b581a2 |
46 | # ->bstr() to see if an object is returned |
ee15d750 |
47 | $try .= '$x->exponent()->bstr();'; |
48 | } elsif ($f eq "mantissa") { |
48b581a2 |
49 | # ->bstr() to see if an object is returned |
ee15d750 |
50 | $try .= '$x->mantissa()->bstr();'; |
027dc388 |
51 | } elsif ($f eq "numify") { |
52 | $try .= "\$x->numify();"; |
53 | } elsif ($f eq "length") { |
54 | $try .= "\$x->length();"; |
55 | # some unary ops (test the bxxx form, since that is done by AUTOLOAD) |
56 | } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|abs)$/) { |
394e6ffb |
57 | $try .= "\$x->f$1();"; |
027dc388 |
58 | # some is_xxx test function |
59 | } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan)$/) { |
60 | $try .= "\$x->$f();"; |
ee15d750 |
61 | } elsif ($f eq "as_number") { |
62 | $try .= '$x->as_number();'; |
ee15d750 |
63 | } elsif ($f eq "finc") { |
64 | $try .= '++$x;'; |
65 | } elsif ($f eq "fdec") { |
66 | $try .= '--$x;'; |
67 | }elsif ($f eq "fround") { |
68 | $try .= "$setup; \$x->fround($args[1]);"; |
69 | } elsif ($f eq "ffround") { |
70 | $try .= "$setup; \$x->ffround($args[1]);"; |
71 | } elsif ($f eq "fsqrt") { |
72 | $try .= "$setup; \$x->fsqrt();"; |
73 | } |
74 | else |
75 | { |
76 | $try .= "\$y = new $class \"$args[1]\";"; |
77 | if ($f eq "fcmp") { |
78 | $try .= '$x <=> $y;'; |
79 | } elsif ($f eq "facmp") { |
80 | $try .= '$x->facmp($y);'; |
81 | } elsif ($f eq "fpow") { |
82 | $try .= '$x ** $y;'; |
83 | } elsif ($f eq "fadd") { |
84 | $try .= '$x + $y;'; |
85 | } elsif ($f eq "fsub") { |
86 | $try .= '$x - $y;'; |
87 | } elsif ($f eq "fmul") { |
88 | $try .= '$x * $y;'; |
89 | } elsif ($f eq "fdiv") { |
90 | $try .= "$setup; \$x / \$y;"; |
394e6ffb |
91 | } elsif ($f eq "frsft") { |
92 | $try .= '$x >> $y;'; |
93 | } elsif ($f eq "flsft") { |
94 | $try .= '$x << $y;'; |
ee15d750 |
95 | } elsif ($f eq "fmod") { |
96 | $try .= '$x % $y;'; |
97 | } else { warn "Unknown op '$f'"; } |
98 | } |
e745a66c |
99 | # print "# Trying: '$try'\n"; |
ee15d750 |
100 | $ans1 = eval $try; |
101 | if ($ans =~ m|^/(.*)$|) |
102 | { |
103 | my $pat = $1; |
104 | if ($ans1 =~ /$pat/) |
105 | { |
106 | ok (1,1); |
107 | } |
108 | else |
109 | { |
110 | print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0); |
111 | } |
112 | } |
113 | else |
114 | { |
115 | if ($ans eq "") |
116 | { |
117 | ok_undef ($ans1); |
118 | } |
119 | else |
120 | { |
121 | print "# Tried: '$try'\n" if !ok ($ans1, $ans); |
122 | if (ref($ans1) eq "$class") |
123 | { |
027dc388 |
124 | # float numbers are normalized (for now), so mantissa shouldn't have |
125 | # trailing zeros |
ee15d750 |
126 | #print $ans1->_trailing_zeros(),"\n"; |
127 | print "# Has trailing zeros after '$try'\n" |
128 | if !ok ($ans1->{_m}->_trailing_zeros(), 0); |
129 | } |
130 | } |
131 | } # end pattern or string |
132 | } |
133 | } # end while |
134 | |
394e6ffb |
135 | # check whether $class->new( Math::BigInt->new()) destroys it |
136 | # ($y == 12 in this case) |
ee15d750 |
137 | $x = Math::BigInt->new(1200); $y = $class->new($x); |
138 | ok ($y,1200); ok ($x,1200); |
139 | |
140 | ############################################################################### |
141 | # fdiv() in list context |
142 | $x = $class->bzero(); ($x,$y) = $x->fdiv(0); |
143 | ok ($x,'NaN'); ok ($y,'NaN'); |
144 | |
145 | # fdiv() in list context |
146 | $x = $class->bzero(); ($x,$y) = $x->fdiv(1); |
147 | ok ($x,0); ok ($y,0); |
148 | |
394e6ffb |
149 | $x = $class->new(2); $x->fzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
150 | $x = $class->new(2); $x->finf(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
151 | $x = $class->new(2); $x->fone(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
152 | $x = $class->new(2); $x->fnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
153 | |
154 | 1; # all done |
ee15d750 |
155 | |
156 | ############################################################################### |
157 | # Perl 5.005 does not like ok ($x,undef) |
158 | |
159 | sub ok_undef |
160 | { |
161 | my $x = shift; |
162 | |
163 | ok (1,1) and return if !defined $x; |
164 | ok ($x,'undef'); |
165 | } |
166 | |
167 | __DATA__ |
394e6ffb |
168 | &frsft |
169 | #NaNfrsft:NaN |
170 | 0:2:0 |
171 | 1:1:0.5 |
172 | 2:1:1 |
173 | 4:1:2 |
174 | 123:1:61.5 |
175 | 32:3:4 |
176 | &flsft |
177 | #NaNflsft:NaN |
178 | 2:1:4 |
179 | 4:3:32 |
180 | 5:3:40 |
181 | 1:2:4 |
182 | 0:5:0 |
ee15d750 |
183 | &fnorm |
184 | 1:1 |
185 | -0:0 |
186 | fnormNaN:NaN |
187 | +inf:inf |
188 | -inf:-inf |
189 | 123:123 |
190 | -123.4567:-123.4567 |
027dc388 |
191 | # invalid inputs |
192 | 1__2:NaN |
193 | 1E1__2:NaN |
194 | 11__2E2:NaN |
195 | #1.E3:NaN |
196 | .2E-3.:NaN |
197 | #1e3e4:NaN |
198 | .2E2:20 |
ee15d750 |
199 | &as_number |
200 | 0:0 |
201 | 1:1 |
202 | 1.2:1 |
203 | 2.345:2 |
204 | -2:-2 |
205 | -123.456:-123 |
206 | -200:-200 |
207 | &finf |
208 | 1:+:inf |
209 | 2:-:-inf |
210 | 3:abc:inf |
211 | &numify |
212 | 0:0e+1 |
213 | +1:1e+0 |
214 | 1234:1234e+0 |
215 | NaN:NaN |
216 | +inf:inf |
217 | -inf:-inf |
218 | &fnan |
219 | abc:NaN |
220 | 2:NaN |
221 | -2:NaN |
222 | 0:NaN |
223 | &fone |
224 | 2:+:1 |
225 | -2:-:-1 |
226 | -2:+:1 |
227 | 2:-:-1 |
228 | 0::1 |
229 | -2::1 |
230 | abc::1 |
231 | 2:abc:1 |
232 | &fsstr |
233 | +inf:inf |
234 | -inf:-inf |
235 | abcfsstr:NaN |
236 | 1234.567:1234567e-3 |
237 | &fstr |
238 | +inf:::inf |
239 | -inf:::-inf |
240 | abcfstr:::NaN |
241 | 1234.567:9::1234.56700 |
242 | 1234.567::-6:1234.567000 |
243 | 12345:5::12345 |
244 | 0.001234:6::0.00123400 |
245 | 0.001234::-8:0.00123400 |
246 | 0:4::0 |
247 | 0::-4:0.0000 |
248 | &fnorm |
249 | inf:inf |
250 | +inf:inf |
251 | -inf:-inf |
252 | +infinity:NaN |
253 | +-inf:NaN |
254 | abc:NaN |
255 | 1 a:NaN |
256 | 1bcd2:NaN |
257 | 11111b:NaN |
258 | +1z:NaN |
259 | -1z:NaN |
260 | 0:0 |
261 | +0:0 |
262 | +00:0 |
263 | +0_0_0:0 |
264 | 000000_0000000_00000:0 |
265 | -0:0 |
266 | -0000:0 |
267 | +1:1 |
268 | +01:1 |
269 | +001:1 |
270 | +00000100000:100000 |
271 | 123456789:123456789 |
272 | -1:-1 |
273 | -01:-1 |
274 | -001:-1 |
275 | -123456789:-123456789 |
276 | -00000100000:-100000 |
277 | 123.456a:NaN |
278 | 123.456:123.456 |
279 | 0.01:0.01 |
280 | .002:0.002 |
281 | +.2:0.2 |
282 | -0.0003:-0.0003 |
283 | -.0000000004:-0.0000000004 |
284 | 123456E2:12345600 |
285 | 123456E-2:1234.56 |
286 | -123456E2:-12345600 |
287 | -123456E-2:-1234.56 |
288 | 1e1:10 |
289 | 2e-11:0.00000000002 |
290 | # excercise _split |
291 | .02e-1:0.002 |
292 | 000001:1 |
293 | -00001:-1 |
294 | -1:-1 |
295 | 000.01:0.01 |
296 | -000.0023:-0.0023 |
297 | 1.1e1:11 |
298 | -3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
299 | -4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004 |
300 | &fpow |
301 | 2:2:4 |
302 | 1:2:1 |
303 | 1:3:1 |
304 | -1:2:1 |
305 | -1:3:-1 |
306 | 123.456:2:15241.383936 |
307 | 2:-2:0.25 |
308 | 2:-3:0.125 |
309 | 128:-2:0.00006103515625 |
310 | abc:123.456:NaN |
311 | 123.456:abc:NaN |
312 | +inf:123.45:inf |
313 | -inf:123.45:-inf |
314 | +inf:-123.45:inf |
315 | -inf:-123.45:-inf |
316 | &fneg |
317 | fnegNaN:NaN |
318 | +inf:-inf |
319 | -inf:inf |
320 | +0:0 |
321 | +1:-1 |
322 | -1:1 |
323 | +123456789:-123456789 |
324 | -123456789:123456789 |
325 | +123.456789:-123.456789 |
326 | -123456.789:123456.789 |
327 | &fabs |
328 | fabsNaN:NaN |
329 | +inf:inf |
330 | -inf:inf |
331 | +0:0 |
332 | +1:1 |
333 | -1:1 |
334 | +123456789:123456789 |
335 | -123456789:123456789 |
336 | +123.456789:123.456789 |
337 | -123456.789:123456.789 |
338 | &fround |
339 | $round_mode = "trunc" |
340 | +inf:5:inf |
341 | -inf:5:-inf |
342 | 0:5:0 |
343 | NaNfround:5:NaN |
344 | +10123456789:5:10123000000 |
345 | -10123456789:5:-10123000000 |
346 | +10123456789.123:5:10123000000 |
347 | -10123456789.123:5:-10123000000 |
348 | +10123456789:9:10123456700 |
349 | -10123456789:9:-10123456700 |
350 | +101234500:6:101234000 |
351 | -101234500:6:-101234000 |
352 | $round_mode = "zero" |
353 | +20123456789:5:20123000000 |
354 | -20123456789:5:-20123000000 |
355 | +20123456789.123:5:20123000000 |
356 | -20123456789.123:5:-20123000000 |
357 | +20123456789:9:20123456800 |
358 | -20123456789:9:-20123456800 |
359 | +201234500:6:201234000 |
360 | -201234500:6:-201234000 |
361 | $round_mode = "+inf" |
362 | +30123456789:5:30123000000 |
363 | -30123456789:5:-30123000000 |
364 | +30123456789.123:5:30123000000 |
365 | -30123456789.123:5:-30123000000 |
366 | +30123456789:9:30123456800 |
367 | -30123456789:9:-30123456800 |
368 | +301234500:6:301235000 |
369 | -301234500:6:-301234000 |
370 | $round_mode = "-inf" |
371 | +40123456789:5:40123000000 |
372 | -40123456789:5:-40123000000 |
373 | +40123456789.123:5:40123000000 |
374 | -40123456789.123:5:-40123000000 |
375 | +40123456789:9:40123456800 |
376 | -40123456789:9:-40123456800 |
377 | +401234500:6:401234000 |
378 | -401234500:6:-401235000 |
379 | $round_mode = "odd" |
380 | +50123456789:5:50123000000 |
381 | -50123456789:5:-50123000000 |
382 | +50123456789.123:5:50123000000 |
383 | -50123456789.123:5:-50123000000 |
384 | +50123456789:9:50123456800 |
385 | -50123456789:9:-50123456800 |
386 | +501234500:6:501235000 |
387 | -501234500:6:-501235000 |
388 | $round_mode = "even" |
389 | +60123456789:5:60123000000 |
390 | -60123456789:5:-60123000000 |
391 | +60123456789:9:60123456800 |
392 | -60123456789:9:-60123456800 |
393 | +601234500:6:601234000 |
394 | -601234500:6:-601234000 |
395 | +60123456789.0123:5:60123000000 |
396 | -60123456789.0123:5:-60123000000 |
397 | &ffround |
398 | $round_mode = "trunc" |
399 | +inf:5:inf |
400 | -inf:5:-inf |
401 | 0:5:0 |
402 | NaNffround:5:NaN |
403 | +1.23:-1:1.2 |
404 | +1.234:-1:1.2 |
405 | +1.2345:-1:1.2 |
406 | +1.23:-2:1.23 |
407 | +1.234:-2:1.23 |
408 | +1.2345:-2:1.23 |
409 | +1.23:-3:1.230 |
410 | +1.234:-3:1.234 |
411 | +1.2345:-3:1.234 |
412 | -1.23:-1:-1.2 |
413 | +1.27:-1:1.2 |
414 | -1.27:-1:-1.2 |
415 | +1.25:-1:1.2 |
416 | -1.25:-1:-1.2 |
417 | +1.35:-1:1.3 |
418 | -1.35:-1:-1.3 |
419 | -0.0061234567890:-1:0.0 |
420 | -0.0061:-1:0.0 |
421 | -0.00612:-1:0.0 |
422 | -0.00612:-2:0.00 |
423 | -0.006:-1:0.0 |
424 | -0.006:-2:0.00 |
425 | -0.0006:-2:0.00 |
426 | -0.0006:-3:0.000 |
427 | -0.0065:-3:/-0\.006|-6e-03 |
428 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
429 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
430 | 0.05:0:0 |
431 | 0.5:0:0 |
432 | 0.51:0:0 |
433 | 0.41:0:0 |
434 | $round_mode = "zero" |
435 | +2.23:-1:/2.2(?:0{5}\d+)? |
436 | -2.23:-1:/-2.2(?:0{5}\d+)? |
437 | +2.27:-1:/2.(?:3|29{5}\d+) |
438 | -2.27:-1:/-2.(?:3|29{5}\d+) |
439 | +2.25:-1:/2.2(?:0{5}\d+)? |
440 | -2.25:-1:/-2.2(?:0{5}\d+)? |
441 | +2.35:-1:/2.(?:3|29{5}\d+) |
442 | -2.35:-1:/-2.(?:3|29{5}\d+) |
443 | -0.0065:-1:0.0 |
444 | -0.0065:-2:/-0\.01|-1e-02 |
445 | -0.0065:-3:/-0\.006|-6e-03 |
446 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
447 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
448 | 0.05:0:0 |
449 | 0.5:0:0 |
450 | 0.51:0:1 |
451 | 0.41:0:0 |
452 | $round_mode = "+inf" |
453 | +3.23:-1:/3.2(?:0{5}\d+)? |
454 | -3.23:-1:/-3.2(?:0{5}\d+)? |
455 | +3.27:-1:/3.(?:3|29{5}\d+) |
456 | -3.27:-1:/-3.(?:3|29{5}\d+) |
457 | +3.25:-1:/3.(?:3|29{5}\d+) |
458 | -3.25:-1:/-3.2(?:0{5}\d+)? |
459 | +3.35:-1:/3.(?:4|39{5}\d+) |
460 | -3.35:-1:/-3.(?:3|29{5}\d+) |
461 | -0.0065:-1:0.0 |
462 | -0.0065:-2:/-0\.01|-1e-02 |
463 | -0.0065:-3:/-0\.006|-6e-03 |
464 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
465 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
466 | 0.05:0:0 |
467 | 0.5:0:1 |
468 | 0.51:0:1 |
469 | 0.41:0:0 |
470 | $round_mode = "-inf" |
471 | +4.23:-1:/4.2(?:0{5}\d+)? |
472 | -4.23:-1:/-4.2(?:0{5}\d+)? |
473 | +4.27:-1:/4.(?:3|29{5}\d+) |
474 | -4.27:-1:/-4.(?:3|29{5}\d+) |
475 | +4.25:-1:/4.2(?:0{5}\d+)? |
476 | -4.25:-1:/-4.(?:3|29{5}\d+) |
477 | +4.35:-1:/4.(?:3|29{5}\d+) |
478 | -4.35:-1:/-4.(?:4|39{5}\d+) |
479 | -0.0065:-1:0.0 |
480 | -0.0065:-2:/-0\.01|-1e-02 |
481 | -0.0065:-3:/-0\.007|-7e-03 |
482 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
483 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
484 | 0.05:0:0 |
485 | 0.5:0:0 |
486 | 0.51:0:1 |
487 | 0.41:0:0 |
488 | $round_mode = "odd" |
489 | +5.23:-1:/5.2(?:0{5}\d+)? |
490 | -5.23:-1:/-5.2(?:0{5}\d+)? |
491 | +5.27:-1:/5.(?:3|29{5}\d+) |
492 | -5.27:-1:/-5.(?:3|29{5}\d+) |
493 | +5.25:-1:/5.(?:3|29{5}\d+) |
494 | -5.25:-1:/-5.(?:3|29{5}\d+) |
495 | +5.35:-1:/5.(?:3|29{5}\d+) |
496 | -5.35:-1:/-5.(?:3|29{5}\d+) |
497 | -0.0065:-1:0.0 |
498 | -0.0065:-2:/-0\.01|-1e-02 |
499 | -0.0065:-3:/-0\.007|-7e-03 |
500 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
501 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
502 | 0.05:0:0 |
503 | 0.5:0:1 |
504 | 0.51:0:1 |
505 | 0.41:0:0 |
506 | $round_mode = "even" |
507 | +6.23:-1:/6.2(?:0{5}\d+)? |
508 | -6.23:-1:/-6.2(?:0{5}\d+)? |
509 | +6.27:-1:/6.(?:3|29{5}\d+) |
510 | -6.27:-1:/-6.(?:3|29{5}\d+) |
511 | +6.25:-1:/6.(?:2(?:0{5}\d+)?|29{5}\d+) |
512 | -6.25:-1:/-6.(?:2(?:0{5}\d+)?|29{5}\d+) |
513 | +6.35:-1:/6.(?:4|39{5}\d+|29{8}\d+) |
514 | -6.35:-1:/-6.(?:4|39{5}\d+|29{8}\d+) |
515 | -0.0065:-1:0.0 |
516 | -0.0065:-2:/-0\.01|-1e-02 |
517 | -0.0065:-3:/-0\.006|-7e-03 |
518 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
519 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
520 | 0.05:0:0 |
521 | 0.5:0:0 |
522 | 0.51:0:1 |
523 | 0.41:0:0 |
524 | 0.01234567:-3:0.012 |
525 | 0.01234567:-4:0.0123 |
526 | 0.01234567:-5:0.01235 |
527 | 0.01234567:-6:0.012346 |
528 | 0.01234567:-7:0.0123457 |
529 | 0.01234567:-8:0.01234567 |
530 | 0.01234567:-9:0.012345670 |
531 | 0.01234567:-12:0.012345670000 |
532 | &fcmp |
533 | fcmpNaN:fcmpNaN: |
534 | fcmpNaN:+0: |
535 | +0:fcmpNaN: |
536 | +0:+0:0 |
537 | -1:+0:-1 |
538 | +0:-1:1 |
539 | +1:+0:1 |
540 | +0:+1:-1 |
541 | -1:+1:-1 |
542 | +1:-1:1 |
543 | -1:-1:0 |
544 | +1:+1:0 |
545 | -1.1:0:-1 |
546 | +0:-1.1:1 |
547 | +1.1:+0:1 |
548 | +0:+1.1:-1 |
549 | +123:+123:0 |
550 | +123:+12:1 |
551 | +12:+123:-1 |
552 | -123:-123:0 |
553 | -123:-12:-1 |
554 | -12:-123:1 |
555 | +123:+124:-1 |
556 | +124:+123:1 |
557 | -123:-124:1 |
558 | -124:-123:-1 |
559 | 0:0.01:-1 |
560 | 0:0.0001:-1 |
561 | 0:-0.0001:1 |
562 | 0:-0.1:1 |
563 | 0.1:0:1 |
564 | 0.00001:0:1 |
565 | -0.0001:0:-1 |
566 | -0.1:0:-1 |
567 | 0:0.0001234:-1 |
568 | 0:-0.0001234:1 |
569 | 0.0001234:0:1 |
570 | -0.0001234:0:-1 |
571 | 0.0001:0.0005:-1 |
572 | 0.0005:0.0001:1 |
573 | 0.005:0.0001:1 |
574 | 0.001:0.0005:1 |
575 | 0.000001:0.0005:-1 |
576 | 0.00000123:0.0005:-1 |
577 | 0.00512:0.0001:1 |
578 | 0.005:0.000112:1 |
579 | 0.00123:0.0005:1 |
580 | 1.5:2:-1 |
581 | 2:1.5:1 |
582 | 1.54321:234:-1 |
583 | 234:1.54321:1 |
584 | # infinity |
585 | -inf:5432112345:-1 |
586 | +inf:5432112345:1 |
587 | -inf:-5432112345:-1 |
588 | +inf:-5432112345:1 |
589 | -inf:54321.12345:-1 |
590 | +inf:54321.12345:1 |
591 | -inf:-54321.12345:-1 |
592 | +inf:-54321.12345:1 |
593 | +inf:+inf:0 |
594 | -inf:-inf:0 |
595 | +inf:-inf:1 |
596 | -inf:+inf:-1 |
597 | # return undef |
598 | +inf:NaN: |
599 | NaN:inf: |
600 | -inf:NaN: |
601 | NaN:-inf: |
602 | &facmp |
603 | fcmpNaN:fcmpNaN: |
604 | fcmpNaN:+0: |
605 | +0:fcmpNaN: |
606 | +0:+0:0 |
607 | -1:+0:1 |
608 | +0:-1:-1 |
609 | +1:+0:1 |
610 | +0:+1:-1 |
611 | -1:+1:0 |
612 | +1:-1:0 |
613 | -1:-1:0 |
614 | +1:+1:0 |
615 | -1.1:0:1 |
616 | +0:-1.1:-1 |
617 | +1.1:+0:1 |
618 | +0:+1.1:-1 |
619 | +123:+123:0 |
620 | +123:+12:1 |
621 | +12:+123:-1 |
622 | -123:-123:0 |
623 | -123:-12:1 |
624 | -12:-123:-1 |
625 | +123:+124:-1 |
626 | +124:+123:1 |
627 | -123:-124:-1 |
628 | -124:-123:1 |
629 | 0:0.01:-1 |
630 | 0:0.0001:-1 |
631 | 0:-0.0001:-1 |
632 | 0:-0.1:-1 |
633 | 0.1:0:1 |
634 | 0.00001:0:1 |
635 | -0.0001:0:1 |
636 | -0.1:0:1 |
637 | 0:0.0001234:-1 |
638 | 0:-0.0001234:-1 |
639 | 0.0001234:0:1 |
640 | -0.0001234:0:1 |
641 | 0.0001:0.0005:-1 |
642 | 0.0005:0.0001:1 |
643 | 0.005:0.0001:1 |
644 | 0.001:0.0005:1 |
645 | 0.000001:0.0005:-1 |
646 | 0.00000123:0.0005:-1 |
647 | 0.00512:0.0001:1 |
648 | 0.005:0.000112:1 |
649 | 0.00123:0.0005:1 |
650 | 1.5:2:-1 |
651 | 2:1.5:1 |
652 | 1.54321:234:-1 |
653 | 234:1.54321:1 |
654 | # infinity |
655 | -inf:5432112345:1 |
656 | +inf:5432112345:1 |
657 | -inf:-5432112345:1 |
658 | +inf:-5432112345:1 |
659 | -inf:54321.12345:1 |
660 | +inf:54321.12345:1 |
661 | -inf:-54321.12345:1 |
662 | +inf:-54321.12345:1 |
663 | +inf:+inf:0 |
664 | -inf:-inf:0 |
665 | +inf:-inf:0 |
666 | -inf:+inf:0 |
48b581a2 |
667 | 5:inf:-1 |
668 | -1:inf:-1 |
669 | 5:-inf:-1 |
670 | -1:-inf:-1 |
ee15d750 |
671 | # return undef |
672 | +inf:facmpNaN: |
673 | facmpNaN:inf: |
674 | -inf:facmpNaN: |
675 | facmpNaN:-inf: |
676 | &fdec |
677 | fdecNaN:NaN |
678 | +inf:inf |
679 | -inf:-inf |
680 | +0:-1 |
681 | +1:0 |
682 | -1:-2 |
683 | 1.23:0.23 |
684 | -1.23:-2.23 |
e745a66c |
685 | 100:99 |
686 | 101:100 |
687 | -100:-101 |
688 | -99:-100 |
689 | -98:-99 |
690 | 99:98 |
ee15d750 |
691 | &finc |
692 | fincNaN:NaN |
693 | +inf:inf |
694 | -inf:-inf |
695 | +0:1 |
696 | +1:2 |
697 | -1:0 |
698 | 1.23:2.23 |
699 | -1.23:-0.23 |
e745a66c |
700 | 100:101 |
701 | -100:-99 |
702 | -99:-98 |
703 | -101:-100 |
704 | 99:100 |
ee15d750 |
705 | &fadd |
706 | abc:abc:NaN |
707 | abc:+0:NaN |
708 | +0:abc:NaN |
709 | +inf:-inf:0 |
710 | -inf:+inf:0 |
711 | +inf:+inf:inf |
712 | -inf:-inf:-inf |
713 | baddNaN:+inf:NaN |
714 | baddNaN:+inf:NaN |
715 | +inf:baddNaN:NaN |
716 | -inf:baddNaN:NaN |
717 | +0:+0:0 |
718 | +1:+0:1 |
719 | +0:+1:1 |
720 | +1:+1:2 |
721 | -1:+0:-1 |
722 | +0:-1:-1 |
723 | -1:-1:-2 |
724 | -1:+1:0 |
725 | +1:-1:0 |
726 | +9:+1:10 |
727 | +99:+1:100 |
728 | +999:+1:1000 |
729 | +9999:+1:10000 |
730 | +99999:+1:100000 |
731 | +999999:+1:1000000 |
732 | +9999999:+1:10000000 |
733 | +99999999:+1:100000000 |
734 | +999999999:+1:1000000000 |
735 | +9999999999:+1:10000000000 |
736 | +99999999999:+1:100000000000 |
737 | +10:-1:9 |
738 | +100:-1:99 |
739 | +1000:-1:999 |
740 | +10000:-1:9999 |
741 | +100000:-1:99999 |
742 | +1000000:-1:999999 |
743 | +10000000:-1:9999999 |
744 | +100000000:-1:99999999 |
745 | +1000000000:-1:999999999 |
746 | +10000000000:-1:9999999999 |
747 | +123456789:+987654321:1111111110 |
748 | -123456789:+987654321:864197532 |
749 | -123456789:-987654321:-1111111110 |
750 | +123456789:-987654321:-864197532 |
751 | 0.001234:0.0001234:0.0013574 |
752 | &fsub |
753 | abc:abc:NaN |
754 | abc:+0:NaN |
755 | +0:abc:NaN |
756 | +inf:-inf:inf |
757 | -inf:+inf:-inf |
758 | +inf:+inf:0 |
759 | -inf:-inf:0 |
760 | baddNaN:+inf:NaN |
761 | baddNaN:+inf:NaN |
762 | +inf:baddNaN:NaN |
763 | -inf:baddNaN:NaN |
764 | +0:+0:0 |
765 | +1:+0:1 |
766 | +0:+1:-1 |
767 | +1:+1:0 |
768 | -1:+0:-1 |
769 | +0:-1:1 |
770 | -1:-1:0 |
771 | -1:+1:-2 |
772 | +1:-1:2 |
773 | +9:+1:8 |
774 | +99:+1:98 |
775 | +999:+1:998 |
776 | +9999:+1:9998 |
777 | +99999:+1:99998 |
778 | +999999:+1:999998 |
779 | +9999999:+1:9999998 |
780 | +99999999:+1:99999998 |
781 | +999999999:+1:999999998 |
782 | +9999999999:+1:9999999998 |
783 | +99999999999:+1:99999999998 |
784 | +10:-1:11 |
785 | +100:-1:101 |
786 | +1000:-1:1001 |
787 | +10000:-1:10001 |
788 | +100000:-1:100001 |
789 | +1000000:-1:1000001 |
790 | +10000000:-1:10000001 |
791 | +100000000:-1:100000001 |
792 | +1000000000:-1:1000000001 |
793 | +10000000000:-1:10000000001 |
794 | +123456789:+987654321:-864197532 |
795 | -123456789:+987654321:-1111111110 |
796 | -123456789:-987654321:864197532 |
797 | +123456789:-987654321:1111111110 |
798 | &fmul |
799 | abc:abc:NaN |
800 | abc:+0:NaN |
801 | +0:abc:NaN |
802 | +inf:NaNmul:NaN |
803 | +inf:NaNmul:NaN |
804 | NaNmul:+inf:NaN |
805 | NaNmul:-inf:NaN |
806 | +inf:+inf:inf |
807 | +inf:-inf:-inf |
808 | +inf:-inf:-inf |
809 | +inf:+inf:inf |
810 | +inf:123.34:inf |
811 | +inf:-123.34:-inf |
812 | -inf:123.34:-inf |
813 | -inf:-123.34:inf |
814 | 123.34:+inf:inf |
815 | -123.34:+inf:-inf |
816 | 123.34:-inf:-inf |
817 | -123.34:-inf:inf |
818 | +0:+0:0 |
819 | +0:+1:0 |
820 | +1:+0:0 |
821 | +0:-1:0 |
822 | -1:+0:0 |
823 | +123456789123456789:+0:0 |
824 | +0:+123456789123456789:0 |
825 | -1:-1:1 |
826 | -1:+1:-1 |
827 | +1:-1:-1 |
828 | +1:+1:1 |
829 | +2:+3:6 |
830 | -2:+3:-6 |
831 | +2:-3:-6 |
832 | -2:-3:6 |
833 | +111:+111:12321 |
834 | +10101:+10101:102030201 |
835 | +1001001:+1001001:1002003002001 |
836 | +100010001:+100010001:10002000300020001 |
837 | +10000100001:+10000100001:100002000030000200001 |
838 | +11111111111:+9:99999999999 |
839 | +22222222222:+9:199999999998 |
840 | +33333333333:+9:299999999997 |
841 | +44444444444:+9:399999999996 |
842 | +55555555555:+9:499999999995 |
843 | +66666666666:+9:599999999994 |
844 | +77777777777:+9:699999999993 |
845 | +88888888888:+9:799999999992 |
846 | +99999999999:+9:899999999991 |
847 | 6:120:720 |
848 | 10:10000:100000 |
849 | &fdiv |
850 | $div_scale = 40; $round_mode = 'even' |
851 | abc:abc:NaN |
852 | abc:+1:abc:NaN |
853 | +1:abc:NaN |
854 | -1:abc:NaN |
855 | 0:abc:NaN |
856 | +0:+0:NaN |
857 | +0:+1:0 |
858 | +1:+0:inf |
859 | +3214:+0:inf |
860 | +0:-1:0 |
861 | -1:+0:-inf |
862 | -3214:+0:-inf |
863 | +1:+1:1 |
864 | -1:-1:1 |
865 | +1:-1:-1 |
866 | -1:+1:-1 |
867 | +1:+2:0.5 |
868 | +2:+1:2 |
869 | 123:+inf:0 |
870 | 123:-inf:0 |
871 | +10:+5:2 |
872 | +100:+4:25 |
873 | +1000:+8:125 |
874 | +10000:+16:625 |
875 | +10000:-16:-625 |
876 | +999999999999:+9:111111111111 |
877 | +999999999999:+99:10101010101 |
878 | +999999999999:+999:1001001001 |
879 | +999999999999:+9999:100010001 |
880 | +999999999999999:+99999:10000100001 |
881 | +1000000000:+9:111111111.1111111111111111111111111111111 |
882 | +2000000000:+9:222222222.2222222222222222222222222222222 |
883 | +3000000000:+9:333333333.3333333333333333333333333333333 |
884 | +4000000000:+9:444444444.4444444444444444444444444444444 |
885 | +5000000000:+9:555555555.5555555555555555555555555555556 |
886 | +6000000000:+9:666666666.6666666666666666666666666666667 |
887 | +7000000000:+9:777777777.7777777777777777777777777777778 |
888 | +8000000000:+9:888888888.8888888888888888888888888888889 |
889 | +9000000000:+9:1000000000 |
890 | +35500000:+113:314159.2920353982300884955752212389380531 |
891 | +71000000:+226:314159.2920353982300884955752212389380531 |
892 | +106500000:+339:314159.2920353982300884955752212389380531 |
893 | +1000000000:+3:333333333.3333333333333333333333333333333 |
894 | 2:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447 |
394e6ffb |
895 | 123456:1:123456 |
ee15d750 |
896 | $div_scale = 20 |
897 | +1000000000:+9:111111111.11111111111 |
898 | +2000000000:+9:222222222.22222222222 |
899 | +3000000000:+9:333333333.33333333333 |
900 | +4000000000:+9:444444444.44444444444 |
901 | +5000000000:+9:555555555.55555555556 |
902 | +6000000000:+9:666666666.66666666667 |
903 | +7000000000:+9:777777777.77777777778 |
904 | +8000000000:+9:888888888.88888888889 |
905 | +9000000000:+9:1000000000 |
906 | 1:10:0.1 |
907 | 1:100:0.01 |
908 | 1:1000:0.001 |
909 | 1:10000:0.0001 |
910 | 1:504:0.001984126984126984127 |
911 | 2:1.987654321:1.0062111801179738436 |
394e6ffb |
912 | 123456789.123456789123456789123456789:1:123456789.12345678912 |
ee15d750 |
913 | # the next two cases are the "old" behaviour, but are now (>v0.01) different |
914 | #+35500000:+113:314159.292035398230088 |
915 | #+71000000:+226:314159.292035398230088 |
916 | +35500000:+113:314159.29203539823009 |
917 | +71000000:+226:314159.29203539823009 |
918 | +106500000:+339:314159.29203539823009 |
919 | +1000000000:+3:333333333.33333333333 |
920 | $div_scale = 1 |
921 | # round to accuracy 1 after bdiv |
922 | +124:+3:40 |
394e6ffb |
923 | 123456789.1234:1:100000000 |
ee15d750 |
924 | # reset scale for further tests |
925 | $div_scale = 40 |
926 | &fmod |
927 | +0:0:NaN |
928 | +0:1:0 |
929 | +3:1:0 |
930 | #+5:2:1 |
931 | #+9:4:1 |
932 | #+9:5:4 |
933 | #+9000:56:40 |
934 | #+56:9000:56 |
935 | &fsqrt |
936 | +0:0 |
937 | -1:NaN |
938 | -2:NaN |
939 | -16:NaN |
940 | -123.45:NaN |
941 | nanfsqrt:NaN |
942 | +inf:inf |
943 | -inf:NaN |
394e6ffb |
944 | 1:1 |
945 | 2:1.41421356237309504880168872420969807857 |
946 | 4:2 |
947 | 9:3 |
948 | 16:4 |
949 | 100:10 |
950 | 123.456:11.11107555549866648462149404118219234119 |
951 | 15241.38393:123.4559999756998444766131352122991626468 |
952 | 1.44:1.2 |
953 | # sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4 |
954 | 1.44E10:120000 |
955 | 2e10:141421.356237309504880168872420969807857 |
027dc388 |
956 | &is_nan |
957 | 123:0 |
958 | abc:1 |
959 | NaN:1 |
960 | -123:0 |
961 | &is_inf |
962 | +inf::1 |
963 | -inf::1 |
964 | abc::0 |
965 | 1::0 |
966 | NaN::0 |
967 | -1::0 |
968 | +inf:-:0 |
969 | +inf:+:1 |
970 | -inf:-:1 |
971 | -inf:+:0 |
972 | # it must be exactly /^[+-]inf$/ |
973 | +infinity::0 |
974 | -infinity::0 |
ee15d750 |
975 | &is_odd |
976 | abc:0 |
977 | 0:0 |
978 | -1:1 |
979 | -3:1 |
980 | 1:1 |
981 | 3:1 |
982 | 1000001:1 |
983 | 1000002:0 |
984 | +inf:0 |
985 | -inf:0 |
986 | 123.45:0 |
987 | -123.45:0 |
988 | 2:0 |
989 | &is_even |
990 | abc:0 |
991 | 0:1 |
992 | -1:0 |
993 | -3:0 |
994 | 1:0 |
995 | 3:0 |
996 | 1000001:0 |
997 | 1000002:1 |
998 | 2:1 |
999 | +inf:0 |
1000 | -inf:0 |
1001 | 123.456:0 |
1002 | -123.456:0 |
1003 | &is_positive |
1004 | 0:1 |
1005 | 1:1 |
1006 | -1:0 |
1007 | -123:0 |
1008 | NaN:0 |
1009 | -inf:0 |
1010 | +inf:1 |
1011 | &is_negative |
1012 | 0:0 |
1013 | 1:0 |
1014 | -1:1 |
1015 | -123:1 |
1016 | NaN:0 |
1017 | -inf:1 |
1018 | +inf:0 |
1019 | &parts |
1020 | 0:0 1 |
1021 | 1:1 0 |
1022 | 123:123 0 |
1023 | -123:-123 0 |
1024 | -1200:-12 2 |
1025 | NaNparts:NaN NaN |
1026 | +inf:inf inf |
1027 | -inf:-inf inf |
1028 | &exponent |
1029 | 0:1 |
1030 | 1:0 |
1031 | 123:0 |
1032 | -123:0 |
1033 | -1200:2 |
1034 | +inf:inf |
1035 | -inf:inf |
1036 | NaNexponent:NaN |
1037 | &mantissa |
1038 | 0:0 |
1039 | 1:1 |
1040 | 123:123 |
1041 | -123:-123 |
1042 | -1200:-12 |
1043 | +inf:inf |
1044 | -inf:-inf |
1045 | NaNmantissa:NaN |
1046 | &length |
1047 | 123:3 |
1048 | -123:3 |
1049 | 0:1 |
1050 | 1:1 |
1051 | 12345678901234567890:20 |
1052 | &is_zero |
1053 | NaNzero:0 |
1054 | +inf:0 |
1055 | -inf:0 |
1056 | 0:1 |
1057 | -1:0 |
1058 | 1:0 |
1059 | &is_one |
1060 | NaNone:0 |
1061 | +inf:0 |
1062 | -inf:0 |
1063 | 0:0 |
1064 | 2:0 |
1065 | 1:1 |
1066 | -1:0 |
1067 | -2:0 |
027dc388 |
1068 | &ffloor |
ee15d750 |
1069 | 0:0 |
1070 | abc:NaN |
1071 | +inf:inf |
1072 | -inf:-inf |
1073 | 1:1 |
1074 | -51:-51 |
1075 | -51.2:-52 |
1076 | 12.2:12 |
027dc388 |
1077 | &fceil |
ee15d750 |
1078 | 0:0 |
1079 | abc:NaN |
1080 | +inf:inf |
1081 | -inf:-inf |
1082 | 1:1 |
1083 | -51:-51 |
1084 | -51.2:-51 |
1085 | 12.2:13 |