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