1 #include this file into another for subclass testing
3 my $version = ${"$class\::VERSION"};
7 ##############################################################################
8 # for testing inheritance of _swap
12 use Math::BigInt lib => $main::CL;
14 @ISA = (qw/Math::BigInt/);
17 # customized overload for sub, since original does not use swap there
18 '-' => sub { my @a = ref($_[0])->_swap(@_);
23 # a fake _swap, which reverses the params
24 my $self = shift; # for override in subclass
27 my $c = ref ($_[0] ) || 'Math::Foo';
28 return ( $_[0]->copy(), $_[1] );
32 return ( Math::Foo->new($_[1]), $_[0] );
36 ##############################################################################
39 my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
41 my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
45 $_ =~ s/[\n\r]//g; # remove newlines
46 next if /^#/; # skip comments
53 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
56 @args = split(/:/,$_,99); $ans = pop(@args);
57 $expected_class = $class;
58 if ($ans =~ /(.*?)=(.*)/)
60 $expected_class = $2; $ans = $1;
62 $try = "\$x = $class->new(\"$args[0]\");";
65 $try = "\$x = $class->bnorm(\"$args[0]\");";
67 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
68 $try .= "\$x->$f() || 0;";
69 } elsif ($f eq "is_inf") {
70 $try .= "\$x->is_inf('$args[1]');";
71 } elsif ($f eq "binf") {
72 $try .= "\$x->binf('$args[1]');";
73 } elsif ($f eq "bone") {
74 $try .= "\$x->bone('$args[1]');";
76 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
78 } elsif ($f =~ /^(numify|length|stringify|as_hex|as_bin)$/) {
80 } elsif ($f eq "exponent"){
81 # ->bstr() to see if an object is returned
82 $try .= '$x = $x->exponent()->bstr();';
83 } elsif ($f eq "mantissa"){
84 # ->bstr() to see if an object is returned
85 $try .= '$x = $x->mantissa()->bstr();';
86 } elsif ($f eq "parts"){
87 $try .= '($m,$e) = $x->parts();';
88 # ->bstr() to see if an object is returned
89 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
90 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
92 }elsif ($f eq "bexp"){
93 $try .= "\$x->bexp();";
94 } elsif ($f eq "bpi"){
95 $try .= "$class\->bpi(\$x);";
98 $try .= "\$y = $class->new('$args[1]');";
101 $try .= '$x->bcmp($y);';
102 } elsif ($f eq "bround") {
103 $try .= "$round_mode; \$x->bround(\$y);";
104 } elsif ($f eq "bacmp"){
105 $try .= '$x->bacmp($y);';
106 } elsif ($f eq "badd"){
108 } elsif ($f eq "bsub"){
110 } elsif ($f eq "bmul"){
112 } elsif ($f eq "bdiv"){
114 } elsif ($f eq "bdiv-list"){
115 $try .= 'join (",",$x->bdiv($y));';
117 } elsif ($f =~ /^.=$/){
118 $try .= "\$x $f \$y;";
120 } elsif ($f =~ /^.$/){
121 $try .= "\$x $f \$y;";
122 } elsif ($f eq "bmod"){
124 } elsif ($f eq "bgcd")
126 if (defined $args[2])
128 $try .= " \$z = $class->new('$args[2]'); ";
130 $try .= "$class\::bgcd(\$x, \$y";
131 $try .= ", \$z" if (defined $args[2]);
136 if (defined $args[2])
138 $try .= " \$z = $class->new('$args[2]'); ";
140 $try .= "$class\::blcm(\$x, \$y";
141 $try .= ", \$z" if (defined $args[2]);
143 }elsif ($f eq "blsft"){
144 if (defined $args[2])
146 $try .= "\$x->blsft(\$y,$args[2]);";
150 $try .= "\$x << \$y;";
152 }elsif ($f eq "brsft"){
153 if (defined $args[2])
155 $try .= "\$x->brsft(\$y,$args[2]);";
159 $try .= "\$x >> \$y;";
161 }elsif ($f eq "bnok"){
162 $try .= "\$x->bnok(\$y);";
163 }elsif ($f eq "broot"){
164 $try .= "\$x->broot(\$y);";
165 }elsif ($f eq "blog"){
166 $try .= "\$x->blog(\$y);";
167 }elsif ($f eq "band"){
168 $try .= "\$x & \$y;";
169 }elsif ($f eq "bior"){
170 $try .= "\$x | \$y;";
171 }elsif ($f eq "bxor"){
172 $try .= "\$x ^ \$y;";
173 }elsif ($f eq "bpow"){
174 $try .= "\$x ** \$y;";
175 } elsif( $f eq "bmodinv") {
176 $try .= "\$x->bmodinv(\$y);";
177 }elsif ($f eq "digit"){
178 $try .= "\$x->digit(\$y);";
179 }elsif ($f eq "batan2"){
180 $try .= "\$x->batan2(\$y);";
182 # Functions with three arguments
183 $try .= "\$z = $class->new(\"$args[2]\");";
185 if( $f eq "bmodpow") {
186 $try .= "\$x->bmodpow(\$y,\$z);";
187 } elsif ($f eq "bmuladd"){
188 $try .= "\$x->bmuladd(\$y,\$z);";
189 } else { warn "Unknown op '$f'"; }
191 } # end else all other ops
194 # convert hex/binary targets to decimal
195 if ($ans =~ /^(0x0x|0b0b)/)
197 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
205 # print "try: $try ans: $ans1 $ans\n";
206 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
207 ok (ref($ans),$expected_class) if $expected_class ne $class;
209 # check internal state of number objects
210 is_valid($ans1,$f) if ref $ans1;
211 } # endwhile data tests
216 for (my $i = 1; $i < 10; $i++)
220 ok "@a", "1 2 3 4 5 6 7 8 9";
222 # test whether self-multiplication works correctly (result is 2**64)
223 $try = "\$x = $class->new('4294967296');";
224 $try .= '$a = $x->bmul($x);';
226 print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
228 $try = "\$x = $class->new(10);";
229 $try .= '$a = $x->bpow($x);';
231 print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
233 ###############################################################################
234 # test whether op destroys args or not (should better not)
260 $x = $class->new(-5); $y = -$x;
263 $x = $class->new(-5); $y = abs($x);
267 $y = $class->new(-1);
268 $z = $class->new(5033);
269 my $u = $x->copy()->bmodpow($y,$z);
274 $x = $class->new(-5); $y = -$x; ok ($x,-5); ok ($y,5);
275 $x = $class->new(-5); $y = $x->copy()->bneg(); ok ($x,-5); ok ($y,5);
277 $x = $class->new(-5); $y = $class->new(3); $x->bmul($y); ok ($x,-15); ok ($y,3);
278 $x = $class->new(-5); $y = $class->new(3); $x->badd($y); ok ($x,-2); ok ($y,3);
279 $x = $class->new(-5); $y = $class->new(3); $x->bsub($y); ok ($x,-8); ok ($y,3);
280 $x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); ok ($x,-5); ok ($y,3);
281 $x = $class->new(-5); $y = $class->new(3); $x->bmod($y); ok ($x,1); ok ($y,3);
283 $x = $class->new(5); $y = $class->new(3); $x->bmul($y); ok ($x,15); ok ($y,3);
284 $x = $class->new(5); $y = $class->new(3); $x->badd($y); ok ($x,8); ok ($y,3);
285 $x = $class->new(5); $y = $class->new(3); $x->bsub($y); ok ($x,2); ok ($y,3);
286 $x = $class->new(15); $y = $class->new(3); $x->bdiv($y); ok ($x,5); ok ($y,3);
287 $x = $class->new(5); $y = $class->new(3); $x->bmod($y); ok ($x,2); ok ($y,3);
289 $x = $class->new(5); $y = $class->new(-3); $x->bmul($y); ok ($x,-15); ok($y,-3);
290 $x = $class->new(5); $y = $class->new(-3); $x->badd($y); ok ($x,2); ok($y,-3);
291 $x = $class->new(5); $y = $class->new(-3); $x->bsub($y); ok ($x,8); ok($y,-3);
292 $x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); ok ($x,-5); ok($y,-3);
293 $x = $class->new(5); $y = $class->new(-3); $x->bmod($y); ok ($x,-1); ok($y,-3);
295 ###############################################################################
296 # check whether overloading cmp works
297 $try = "\$x = $class->new(0);";
299 $try .= "'false' if \$x ne \$y;";
301 print "# For '$try'\n" if (!ok "$ans" , "false" );
303 # we cant test for working cmpt with other objects here, we would need a dummy
304 # object with stringify overload for this. see Math::String tests as example
306 ###############################################################################
307 # check reversed order of arguments
309 $try = "\$x = $class->new(10); \$x = 2 ** \$x;";
310 $try .= "'ok' if \$x == 1024;"; $ans = eval $try;
311 print "# For '$try'\n" if (!ok "$ans" , "ok" );
313 $try = "\$x = $class->new(10); \$x = 2 * \$x;";
314 $try .= "'ok' if \$x == 20;"; $ans = eval $try;
315 print "# For '$try'\n" if (!ok "$ans" , "ok" );
317 $try = "\$x = $class->new(10); \$x = 2 + \$x;";
318 $try .= "'ok' if \$x == 12;"; $ans = eval $try;
319 print "# For '$try'\n" if (!ok "$ans" , "ok" );
321 $try = "\$x = $class\->new(10); \$x = 2 - \$x;";
322 $try .= "'ok' if \$x == -8;"; $ans = eval $try;
323 print "# For '$try'\n" if (!ok "$ans" , "ok" );
325 $try = "\$x = $class\->new(10); \$x = 20 / \$x;";
326 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
327 print "# For '$try'\n" if (!ok "$ans" , "ok" );
329 $try = "\$x = $class\->new(3); \$x = 20 % \$x;";
330 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
331 print "# For '$try'\n" if (!ok "$ans" , "ok" );
333 $try = "\$x = $class\->new(7); \$x = 20 & \$x;";
334 $try .= "'ok' if \$x == 4;"; $ans = eval $try;
335 print "# For '$try'\n" if (!ok "$ans" , "ok" );
337 $try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
338 $try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
339 print "# For '$try'\n" if (!ok "$ans" , "ok" );
341 $try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
342 $try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
343 print "# For '$try'\n" if (!ok "$ans" , "ok" );
345 ###############################################################################
346 # check badd(4,5) form
348 $try = "\$x = $class\->badd(4,5);";
349 $try .= "'ok' if \$x == 9;";
351 print "# For '$try'\n" if (!ok "$ans" , "ok" );
353 ###############################################################################
354 # check undefs: NOT DONE YET
356 ###############################################################################
359 $x = $class->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
360 $x = $class->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
362 ###############################################################################
365 @args = Math::BigInt::objectify(2,4,5);
366 ok (scalar @args,3); # $class, 4, 5
367 ok ($args[0] =~ /^Math::BigInt/);
371 @args = Math::BigInt::objectify(0,4,5);
372 ok (scalar @args,3); # $class, 4, 5
373 ok ($args[0] =~ /^Math::BigInt/);
377 @args = Math::BigInt::objectify(2,4,5);
378 ok (scalar @args,3); # $class, 4, 5
379 ok ($args[0] =~ /^Math::BigInt/);
383 @args = Math::BigInt::objectify(2,4,5,6,7);
384 ok (scalar @args,5); # $class, 4, 5, 6, 7
385 ok ($args[0] =~ /^Math::BigInt/);
386 ok ($args[1],4); ok (ref($args[1]),$args[0]);
387 ok ($args[2],5); ok (ref($args[2]),$args[0]);
388 ok ($args[3],6); ok (ref($args[3]),'');
389 ok ($args[4],7); ok (ref($args[4]),'');
391 @args = Math::BigInt::objectify(2,$class,4,5,6,7);
392 ok (scalar @args,5); # $class, 4, 5, 6, 7
393 ok ($args[0],$class);
394 ok ($args[1],4); ok (ref($args[1]),$args[0]);
395 ok ($args[2],5); ok (ref($args[2]),$args[0]);
396 ok ($args[3],6); ok (ref($args[3]),'');
397 ok ($args[4],7); ok (ref($args[4]),'');
399 ###############################################################################
400 # test whether an opp calls objectify properly or not (or at least does what
401 # it should do given non-objects, w/ or w/o objectify())
403 ok ($class->new(123)->badd(123),246);
404 ok ($class->badd(123,321),444);
405 ok ($class->badd(123,$class->new(321)),444);
407 ok ($class->new(123)->bsub(122),1);
408 ok ($class->bsub(321,123),198);
409 ok ($class->bsub(321,$class->new(123)),198);
411 ok ($class->new(123)->bmul(123),15129);
412 ok ($class->bmul(123,123),15129);
413 ok ($class->bmul(123,$class->new(123)),15129);
415 ok ($class->new(15129)->bdiv(123),123);
416 ok ($class->bdiv(15129,123),123);
417 ok ($class->bdiv(15129,$class->new(123)),123);
419 ok ($class->new(15131)->bmod(123),2);
420 ok ($class->bmod(15131,123),2);
421 ok ($class->bmod(15131,$class->new(123)),2);
423 ok ($class->new(2)->bpow(16),65536);
424 ok ($class->bpow(2,16),65536);
425 ok ($class->bpow(2,$class->new(16)),65536);
427 ok ($class->new(2**15)->brsft(1),2**14);
428 ok ($class->brsft(2**15,1),2**14);
429 ok ($class->brsft(2**15,$class->new(1)),2**14);
431 ok ($class->new(2**13)->blsft(1),2**14);
432 ok ($class->blsft(2**13,1),2**14);
433 ok ($class->blsft(2**13,$class->new(1)),2**14);
435 ###############################################################################
436 # test for floating-point input (other tests in bnorm() below)
438 $z = 1050000000000000; # may be int on systems with 64bit?
439 $x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
440 $z = 1e+129; # definitely a float (may fail on UTS)
441 # don't compare to $z, since some Perl versions stringify $z into something
442 # like '1.e+129' or something equally ugly
443 $x = $class->new($z); ok ($x->bsstr(),'1e+129');
445 ###############################################################################
446 # test for whitespace inlcuding newlines to be handled correctly
448 # ok ($Math::BigInt::strict,1); # the default
451 qw/1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890/)
453 my $m = $class->new($c);
454 ok ($class->new("$c"),$m);
455 ok ($class->new(" $c"),$m);
456 ok ($class->new("$c "),$m);
457 ok ($class->new(" $c "),$m);
458 ok ($class->new("\n$c"),$m);
459 ok ($class->new("$c\n"),$m);
460 ok ($class->new("\n$c\n"),$m);
461 ok ($class->new(" \n$c\n"),$m);
462 ok ($class->new(" \n$c \n"),$m);
463 ok ($class->new(" \n$c\n "),$m);
464 ok ($class->new(" \n$c\n1"),'NaN');
465 ok ($class->new("1 \n$c\n1"),'NaN');
468 ###############################################################################
469 # prime number tests, also test for **= and length()
470 # found on: http://www.utm.edu/research/primes/notes/by_year.html
473 $x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
474 ok ($x,"20988936657440586486151264256610222593863921");
475 ok ($x->length(),length "20988936657440586486151264256610222593863921");
478 $x = $class->new(2); $x **= 127; $x--;
479 ok ($x,"170141183460469231731687303715884105727");
481 $x = $class->new('215960156869840440586892398248');
482 ($x,$y) = $x->length();
483 ok ($x,30); ok ($y,0);
485 $x = $class->new('1_000_000_000_000');
486 ($x,$y) = $x->length();
487 ok ($x,13); ok ($y,0);
490 $x = $class->new('2');
491 my $y = $class->new('18');
492 ok ($x <<= $y, 2 << 18);
497 # I am afraid the following is not yet possible due to slowness
498 # Also, testing for 2 meg output is a bit hard ;)
499 #$x = $class->new(2); $x **= 6972593; $x--;
501 # 593573509*2^332162+1 has exactly 1,000,000 digits
502 # takes about 24 mins on 300 Mhz, so cannot be done yet ;)
503 #$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
504 #ok ($x->length(),1_000_000);
506 ###############################################################################
507 # inheritance and overriding of _swap
509 $x = Math::Foo->new(5);
510 $x = $x - 8; # 8 - 5 instead of 5-8
512 ok (ref($x),'Math::Foo');
514 $x = Math::Foo->new(5);
515 $x = 8 - $x; # 5 - 8 instead of 8 - 5
517 ok (ref($x),'Math::Foo');
519 ###############################################################################
520 # Test whether +inf eq inf
521 # This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
522 # hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
523 # like 1e100000 crash on some platforms. So simple test for the string 'inf'
524 $x = $class->new('+inf'); ok ($x,'inf');
526 ###############################################################################
527 ###############################################################################
528 # the followin tests only make sense with Math::BigInt::Calc or BareCalc or
531 exit if $CALC !~ /^Math::BigInt::(|Bare|Fast)Calc$/; # for Pari et al.
533 ###############################################################################
534 # check proper length of internal arrays
536 my $bl = $CL->_base_len();
537 my $BASE = '9' x $bl;
541 $x = $class->new($MAX); is_valid($x); # f.i. 9999
542 $x += 1; ok ($x,$BASE); is_valid($x); # 10000
543 $x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
545 ###############################################################################
548 $x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
549 $x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
551 # +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
552 $x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
553 $x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
554 $x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
555 ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
557 ###############################################################################
558 # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
560 $x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
561 if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
563 $x = $class->new($BASE+3); $x++;
564 if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
566 # test for +0 instead of int():
567 $x = $class->new($MAX); ok ($x->length(), length($MAX));
569 ###############################################################################
570 # test bug that $class->digit($string) did not work
572 ok ($class->digit(123,2),1);
574 ###############################################################################
575 # bug in sub where number with at least 6 trailing zeros after any op failed
577 $x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
581 ###############################################################################
582 # bug in shortcut in mul()
584 # construct a number with a zero-hole of BASE_LEN_SMALL
586 my @bl = $CL->_base_len(); my $bl = $bl[4];
588 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
590 $x = $class->new($x)->bmul($y);
591 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
593 for (my $i = 1; $i <= $bl; $i++)
595 $y .= $i; $d = $i.$d;
597 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
601 #############################################################################
602 # see if mul shortcut for small numbers works
605 $x = $class->new($x);
606 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
607 ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
610 ###############################################################################
611 # bug with rest "-0" in div, causing further div()s to fail
613 $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
615 ok ($y,'0'); is_valid($y); # $y not '-0'
617 ###############################################################################
618 # bug in $x->bmod($y)
620 # if $x < 0 and $y > 0
621 $x = $class->new('-629'); ok ($x->bmod(5033),4404);
623 ###############################################################################
624 # bone/binf etc as plain calls (Lite failed them)
626 ok ($class->bzero(),0);
627 ok ($class->bone(),1);
628 ok ($class->bone('+'),1);
629 ok ($class->bone('-'),-1);
630 ok ($class->bnan(),'NaN');
631 ok ($class->binf(),'inf');
632 ok ($class->binf('+'),'inf');
633 ok ($class->binf('-'),'-inf');
634 ok ($class->binf('-inf'),'-inf');
636 ###############################################################################
639 ok ($class->new(1)->is_one('-'),0);
640 ok ($class->new(-1)->is_one('-'),1);
641 ok ($class->new(1)->is_one(),1);
642 ok ($class->new(-1)->is_one(),0);
644 ###############################################################################
645 # [perl #30609] bug with $x -= $x not beeing 0, but 2*$x
647 $x = $class->new(3); $x -= $x; ok ($x, 0);
648 $x = $class->new(-3); $x -= $x; ok ($x, 0);
649 $x = $class->new('NaN'); $x -= $x; ok ($x->is_nan(), 1);
650 $x = $class->new('inf'); $x -= $x; ok ($x->is_nan(), 1);
651 $x = $class->new('-inf'); $x -= $x; ok ($x->is_nan(), 1);
653 $x = $class->new('NaN'); $x += $x; ok ($x->is_nan(), 1);
654 $x = $class->new('inf'); $x += $x; ok ($x->is_inf(), 1);
655 $x = $class->new('-inf'); $x += $x; ok ($x->is_inf('-'), 1);
656 $x = $class->new(3); $x += $x; ok ($x, 6);
657 $x = $class->new(-3); $x += $x; ok ($x, -6);
659 $x = $class->new(3); $x *= $x; ok ($x, 9);
660 $x = $class->new(-3); $x *= $x; ok ($x, 9);
661 $x = $class->new(3); $x /= $x; ok ($x, 1);
662 $x = $class->new(-3); $x /= $x; ok ($x, 1);
663 $x = $class->new(3); $x %= $x; ok ($x, 0);
664 $x = $class->new(-3); $x %= $x; ok ($x, 0);
666 ###############################################################################
671 ###############################################################################
672 ###############################################################################
673 # Perl 5.005 does not like ok ($x,undef)
679 ok (1,1) and return if !defined $x;
683 ###############################################################################
684 # sub to check validity of a BigInt internally, to ensure that no op leaves a
685 # number object in an invalid state (f.i. "-0")
693 # allow the check to pass for all Lite, and all MBI and subclasses
695 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
697 if (ref($x) ne 'Math::BigInt::Lite')
700 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
701 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
703 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
704 $e = $CALC->_check($x->{value}) if $e eq '0';
707 # test done, see if error did crop up
708 ok (1,1), return if ($e eq '0');
710 ok (1,$e." after op '$f'");
770 2251799813685248:8:17
771 72057594037927936:2:56
772 144115188075855872:2:57
773 288230376151711744:2:58
774 576460752303423488:2:59
776 1329227995784915872903807060280344576:2:120
777 # $x == $base => result 1
779 # $x < $base => result 0 ($base ** 0 <= $x)
781 # $x == 1 => result 0
835 -123456789:+987654321:-1
836 +123456789:-987654321:-1
837 +987654321:+123456789:1
838 -987654321:+123456789:1
888 0b10000000000001:8193
889 0b100000000000001:16385
890 0b1000000000000001:32769
891 0b10000000000000001:65537
892 0b100000000000000001:131073
893 0b1000000000000000001:262145
894 0b10000000000000000001:524289
895 0b100000000000000000001:1048577
896 0b1000000000000000000001:2097153
897 0b10000000000000000000001:4194305
898 0b100000000000000000000001:8388609
899 0b1000000000000000000000001:16777217
900 0b10000000000000000000000001:33554433
901 0b100000000000000000000000001:67108865
902 0b1000000000000000000000000001:134217729
903 0b10000000000000000000000000001:268435457
904 0b100000000000000000000000000001:536870913
905 0b1000000000000000000000000000001:1073741825
906 0b10000000000000000000000000000001:2147483649
907 0b100000000000000000000000000000001:4294967297
908 0b1000000000000000000000000000000001:8589934593
909 0b10000000000000000000000000000000001:17179869185
921 0x1_2_3_4_56_78:305419896
922 0xa_b_c_d_e_f:11259375
951 0x40000001:1073741825
952 0x80000001:2147483649
953 0x100000001:4294967297
954 0x200000001:8589934593
955 0x400000001:17179869185
956 0x800000001:34359738369
957 # bug found by Mark Lakata in Calc.pm creating too big one-element numbers in _from_hex()
958 0x2dd59e18a125dbed30a6ab1d93e9c855569f44f75806f0645dc9a2e98b808c3:1295719234436071846486578237372801883390756472611551858964079371952886122691
972 # only one underscore between two digits
990 # bug with two E's in number beeing valid
994 # bug with two '.' in number beeing valid
1017 0123456789:123456789
1018 01234567891:1234567891
1019 012345678912:12345678912
1020 0123456789123:123456789123
1021 01234567891234:1234567891234
1022 # some inputs that result in zero
1053 000000000000000000:0
1064 -123456789:-123456789
1065 -00000100000:-100000
1073 # floating point input
1081 # non-integer numbers
1120 # it must be exactly /^[+-]inf$/
1127 +1:+48:281474976710656
1130 +12345:4:10:123450000
1136 1234567890123:12:10:1234567890123000000000000
1140 -102533203:1:2:-205066406
1145 +281474976710656:+48:1
1156 1230000000000:10:10:123
1157 09876123456789067890:12:10:9876123
1158 1234561234567890123:13:10:123456
1159 820265627:1:2:410132813
1160 # test shifting negative numbers in base 2
1176 -1640531254:2:2:-410132814
1177 -1640531254:1:2:-820265627
1178 -820265627:1:2:-410132814
1179 -205066405:1:2:-102533203
1205 +123456789:-123456789
1206 -123456789:123456789
1214 +123456789:123456789
1215 -123456789:123456789
1240 -123456789:987654321:-1
1241 +123456789:-987654321:1
1242 -987654321:123456789:-1
1301 +9999999:+1:10000000
1302 +99999999:+1:100000000
1303 +999999999:+1:1000000000
1304 +9999999999:+1:10000000000
1305 +99999999999:+1:100000000000
1312 +10000000:-1:9999999
1313 +100000000:-1:99999999
1314 +1000000000:-1:999999999
1315 +10000000000:-1:9999999999
1316 +123456789:987654321:1111111110
1317 -123456789:987654321:864197532
1318 -123456789:-987654321:-1111111110
1319 +123456789:-987654321:-864197532
1323 -1:10000001:10000000
1324 -1:100000001:100000000
1325 -1:1000000001:1000000000
1326 -1:10000000001:10000000000
1327 -1:100000000001:100000000000
1328 -1:1000000000001:1000000000000
1329 -1:10000000000001:10000000000000
1332 -1:-1000001:-1000002
1333 -1:-10000001:-10000002
1334 -1:-100000001:-100000002
1335 -1:-1000000001:-1000000002
1336 -1:-10000000001:-10000000002
1337 -1:-100000000001:-100000000002
1338 -1:-1000000000001:-1000000000002
1339 -1:-10000000000001:-10000000000002
1364 +99999999:+1:99999998
1365 +999999999:+1:999999998
1366 +9999999999:+1:9999999998
1367 +99999999999:+1:99999999998
1374 +10000000:-1:10000001
1375 +100000000:-1:100000001
1376 +1000000000:-1:1000000001
1377 +10000000000:-1:10000000001
1378 +123456789:+987654321:-864197532
1379 -123456789:+987654321:-1111111110
1380 -123456789:-987654321:864197532
1381 +123456789:-987654321:1111111110
1386 100000001:1:100000000
1387 1000000001:1:1000000000
1388 10000000001:1:10000000000
1389 100000000001:1:100000000000
1390 1000000000001:1:1000000000000
1391 10000000000001:1:10000000000000
1395 10000001:-1:10000002
1396 100000001:-1:100000002
1397 1000000001:-1:1000000002
1398 10000000001:-1:10000000002
1399 100000000001:-1:100000000002
1400 1000000000001:-1:1000000000002
1401 10000000000001:-1:10000000000002
1420 123456789123456789:0:0:0
1421 0:123456789123456789:0:0
1432 10101:10101:0:102030201
1433 1001001:1001001:0:1002003002001
1434 100010001:100010001:0:10002000300020001
1435 10000100001:10000100001:0:100002000030000200001
1436 11111111111:9:0:99999999999
1437 22222222222:9:0:199999999998
1438 33333333333:9:0:299999999997
1439 44444444444:9:0:399999999996
1440 55555555555:9:0:499999999995
1441 66666666666:9:0:599999999994
1442 77777777777:9:0:699999999993
1443 88888888888:9:0:799999999992
1444 99999999999:9:0:899999999991
1445 11111111111:9:1:100000000000
1446 22222222222:9:1:199999999999
1447 33333333333:9:1:299999999998
1448 44444444444:9:1:399999999997
1449 55555555555:9:1:499999999996
1450 66666666666:9:1:599999999995
1451 77777777777:9:1:699999999994
1452 88888888888:9:1:799999999993
1453 99999999999:9:1:899999999992
1460 9999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
1461 2:3:12345678901234567890:12345678901234567896
1479 123456789123456789:0:0
1480 0:123456789123456789:0
1490 10101:10101:102030201
1491 1001001:1001001:1002003002001
1492 100010001:100010001:10002000300020001
1493 10000100001:10000100001:100002000030000200001
1494 11111111111:9:99999999999
1495 22222222222:9:199999999998
1496 33333333333:9:299999999997
1497 44444444444:9:399999999996
1498 55555555555:9:499999999995
1499 66666666666:9:599999999994
1500 77777777777:9:699999999993
1501 88888888888:9:799999999992
1502 99999999999:9:899999999991
1504 +12345:+12345:152399025
1505 +99999:+11111:1111088889
1507 99999:100000:9999900000
1508 999999:1000000:999999000000
1509 9999999:10000000:99999990000000
1510 99999999:100000000:9999999900000000
1511 999999999:1000000000:999999999000000000
1512 9999999999:10000000000:99999999990000000000
1513 99999999999:100000000000:9999999999900000000000
1514 999999999999:1000000000000:999999999999000000000000
1515 9999999999999:10000000000000:99999999999990000000000000
1516 99999999999999:100000000000000:9999999999999900000000000000
1517 999999999999999:1000000000000000:999999999999999000000000000000
1518 9999999999999999:10000000000000000:99999999999999990000000000000000
1519 99999999999999999:100000000000000000:9999999999999999900000000000000000
1520 999999999999999999:1000000000000000000:999999999999999999000000000000000000
1521 9999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1531 # inf handling and general remainder
1537 # see table in documentation in MBI
1556 # exceptions to reminder rule
1560 # test the shortcut in Calc if @$x == @$yorg
1561 1234567812345678:123456712345678:10,688888898
1562 12345671234567:1234561234567:10,58888897
1563 123456123456:12345123456:10,4888896
1564 1234512345:123412345:10,388895
1565 1234567890999999999:1234567890:1000000000,999999999
1566 1234567890000000000:1234567890:1000000000,0
1567 1234567890999999999:9876543210:124999998,9503086419
1568 1234567890000000000:9876543210:124999998,8503086420
1569 96969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
1571 1267650600228229401496703205375:1267650600228229401496703205376:0,1267650600228229401496703205375
1572 # excercise shortcut for numbers of the same length in div
1573 999999999999999999999999999999999:999999999999999999999999999999999:1,0
1574 999999999999999999999999999999999:888888888888888888888888888888888:1,111111111111111111111111111111111
1575 999999999999999999999999999999999:777777777777777777777777777777777:1,222222222222222222222222222222222
1576 999999999999999999999999999999999:666666666666666666666666666666666:1,333333333333333333333333333333333
1577 999999999999999999999999999999999:555555555555555555555555555555555:1,444444444444444444444444444444444
1578 999999999999999999999999999999999:444444444444444444444444444444444:2,111111111111111111111111111111111
1579 999999999999999999999999999999999:333333333333333333333333333333333:3,0
1580 999999999999999999999999999999999:222222222222222222222222222222222:4,111111111111111111111111111111111
1581 999999999999999999999999999999999:111111111111111111111111111111111:9,0
1582 9999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3,0
1583 9999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3,999999999999999999999
1584 9999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3,999999999999999999999999999
1585 9999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4,1999999999999999999999999999
1586 9999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9,999999999999999999999999999
1587 9999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99,99999999999999999999999999
1588 9999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999,9999999999999999999999999
1589 9999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999,999999999999999999999999
1590 9999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999,99999999999999999999999
1591 9999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999,9999999999999999999999
1592 9999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999,999999999999999999999
1598 # inf handling (see table in doc)
1633 1000000000:9:111111111
1634 2000000000:9:222222222
1635 3000000000:9:333333333
1636 4000000000:9:444444444
1637 5000000000:9:555555555
1638 6000000000:9:666666666
1639 7000000000:9:777777777
1640 8000000000:9:888888888
1641 9000000000:9:1000000000
1644 106500000:339:314159
1645 1000000000:3:333333333
1650 999999999999:9:111111111111
1651 999999999999:99:10101010101
1652 999999999999:999:1001001001
1653 999999999999:9999:100010001
1654 999999999999999:99999:10000100001
1655 +1111088889:99999:11111
1670 # bug in Calc with '99999' vs $BASE-1
1671 10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1672 # test the shortcut in Calc if @$x == @$yorg
1673 1234567812345678:123456712345678:10
1674 12345671234567:1234561234567:10
1675 123456123456:12345123456:10
1676 1234512345:123412345:10
1677 1234567890999999999:1234567890:1000000000
1678 1234567890000000000:1234567890:1000000000
1679 1234567890999999999:9876543210:124999998
1680 1234567890000000000:9876543210:124999998
1681 96969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
1682 # bug up to v0.35 in Calc (--$q one too many)
1683 84696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
1684 84696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
1685 84696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
1686 84696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
1687 # excercise shortcut for numbers of the same length in div
1688 999999999999999999999999999999999:999999999999999999999999999999999:1
1689 999999999999999999999999999999999:888888888888888888888888888888888:1
1690 999999999999999999999999999999999:777777777777777777777777777777777:1
1691 999999999999999999999999999999999:666666666666666666666666666666666:1
1692 999999999999999999999999999999999:555555555555555555555555555555555:1
1693 999999999999999999999999999999999:444444444444444444444444444444444:2
1694 999999999999999999999999999999999:333333333333333333333333333333333:3
1695 999999999999999999999999999999999:222222222222222222222222222222222:4
1696 999999999999999999999999999999999:111111111111111111111111111111111:9
1697 9999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3
1698 9999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3
1699 9999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3
1700 9999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4
1701 9999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9
1702 9999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99
1703 9999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999
1704 9999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999
1705 9999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999
1706 9999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999
1707 9999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999
1708 # bug with shortcut in Calc 0.44
1709 949418181818187070707070707070707070:181818181853535353535353535353535353:5
1711 # format: number:modulus:result
1712 # bmodinv Data errors
1716 # bmodinv Expected Results from normal use
1723 324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
1724 ## bmodinv Error cases / useless use of function
1731 # format: number:exponent:modulus:result
1732 # bmodpow Data errors
1740 # bmodpow Expected results
1746 98436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1747 # bmodpow Error cases
1753 # inf handling, see table in doc
1772 # exceptions to reminder rule
1811 999999999999999:99999:0
1825 152403346:12345:4321
1827 # test shortcuts in Calc
1828 # 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
1835 1234567891234567:9:1
1836 123456789123456789:9:0
1843 1234567891234567:10:7
1844 123456789123456789:10:9
1850 12345678912345:113:53
1851 1234567891234567:113:56
1852 123456789123456789:113:39
1853 # bug in bmod() not modifying the variable in place
1855 # bug in bmod() in Calc in the _div_use_div() shortcut code path,
1856 # when X == X and X was big
1857 111111111111111111111111111111:111111111111111111111111111111:0
1858 12345678901234567890:12345678901234567890:0
1902 +281474976710656:0:0
1903 +281474976710656:1:0
1904 +281474976710656:+281474976710656:281474976710656
1905 281474976710656:-1:281474976710656
1912 # negative argument is bitwise shorter than positive [perl #26559]
1915 # equal arguments are treated special, so also do some test with unequal ones
1916 0xFFFF:0xFFFF:0x0xFFFF
1917 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1918 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1919 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1920 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1921 0xF0F0:0xF0F0:0x0xF0F0
1922 0x0F0F:0x0F0F:0x0x0F0F
1923 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1924 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1925 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1926 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1927 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1928 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1929 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1930 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1931 0x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
1938 +281474976710656:0:281474976710656
1939 +281474976710656:1:281474976710657
1940 +281474976710656:281474976710656:281474976710656
1946 +281474976710656:-1:-1
1951 # equal arguments are treated special, so also do some test with unequal ones
1952 0xFFFF:0xFFFF:0x0xFFFF
1953 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1954 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1955 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1956 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1958 0:0xFFFFFF:0x0xFFFFFF
1959 0:0xFFFFFFFF:0x0xFFFFFFFF
1960 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1961 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1963 0xFFFFFF:0:0x0xFFFFFF
1964 0xFFFFFFFF:0:0x0xFFFFFFFF
1965 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
1966 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
1967 0xF0F0:0xF0F0:0x0xF0F0
1968 0x0F0F:0x0F0F:0x0x0F0F
1969 0xF0F0:0x0F0F:0x0xFFFF
1970 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1971 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1972 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
1973 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1974 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1975 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
1976 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1977 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1978 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
1979 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1980 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1981 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1982 0x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1989 +281474976710656:0:281474976710656
1990 +281474976710656:1:281474976710657
1991 +281474976710656:281474976710656:0
2003 # equal arguments are treated special, so also do some test with unequal ones
2006 0xFFFFFFFF:0xFFFFFFFF:0
2007 0xFFFFFFFFFF:0xFFFFFFFFFF:0
2008 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
2010 0:0xFFFFFF:0x0xFFFFFF
2011 0:0xFFFFFFFF:0x0xFFFFFFFF
2012 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
2013 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
2015 0xFFFFFF:0:0x0xFFFFFF
2016 0xFFFFFFFF:0:0x0xFFFFFFFF
2017 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
2018 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
2021 0xF0F0:0x0F0F:0x0xFFFF
2024 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
2025 0xF0F0F0F0:0xF0F0F0F0:0
2026 0x0F0F0F0F:0x0F0F0F0F:0
2027 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
2028 0xF0F0F0F0F0:0xF0F0F0F0F0:0
2029 0x0F0F0F0F0F:0x0F0F0F0F0F:0
2030 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
2031 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
2032 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
2033 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
2038 +281474976710656:-281474976710657
2111 20:2432902008176640000
2112 22:1124000727777607680000
2113 69:171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
2145 -inf:1234500013:-inf
2146 +inf:-12345000123:inf
2147 -inf:-12345000123:-inf
2168 # 1 ** -x => 1 / (1 ** x)
2188 10:20:100000000000000000000
2189 123456:2:15241383936
2204 10000000000000000:17
2206 215960156869840440586892398248:30
2212 # -$x ** (1/2) => -$y, but not in froot()
2257 18446744073709551616:4:65536
2258 18446744073709551616:8:256
2259 18446744073709551616:16:16
2260 18446744073709551616:32:4
2261 18446744073709551616:64:2
2262 18446744073709551616:128:1
2264 84274086103068221283760416414557757:15:213
2265 # see t/bigroot.t for more tests
2281 4000000000000:2000000
2285 # 2 ** 64 => 2 ** 32
2286 18446744073709551616:4294967296
2287 84274086103068221283760416414557757:290299993288095377
2295 # see t/biglog.t for more tests
2326 # see t/bignok.t for more tests
2341 100:90:17310309456440
2344 $round_mode('trunc')
2354 +10123456789:5:10123000000
2355 -10123456789:5:-10123000000
2356 +10123456789:9:10123456700
2357 -10123456789:9:-10123456700
2358 +101234500:6:101234000
2359 -101234500:6:-101234000
2360 #+101234500:-4:101234000
2361 #-101234500:-4:-101234000
2363 +20123456789:5:20123000000
2364 -20123456789:5:-20123000000
2365 +20123456789:9:20123456800
2366 -20123456789:9:-20123456800
2367 +201234500:6:201234000
2368 -201234500:6:-201234000
2369 #+201234500:-4:201234000
2370 #-201234500:-4:-201234000
2371 +12345000:4:12340000
2372 -12345000:4:-12340000
2374 +30123456789:5:30123000000
2375 -30123456789:5:-30123000000
2376 +30123456789:9:30123456800
2377 -30123456789:9:-30123456800
2378 +301234500:6:301235000
2379 -301234500:6:-301234000
2380 #+301234500:-4:301235000
2381 #-301234500:-4:-301234000
2382 +12345000:4:12350000
2383 -12345000:4:-12340000
2385 +40123456789:5:40123000000
2386 -40123456789:5:-40123000000
2387 +40123456789:9:40123456800
2388 -40123456789:9:-40123456800
2389 +401234500:6:401234000
2390 +401234500:6:401234000
2391 #-401234500:-4:-401235000
2392 #-401234500:-4:-401235000
2393 +12345000:4:12340000
2394 -12345000:4:-12350000
2396 +50123456789:5:50123000000
2397 -50123456789:5:-50123000000
2398 +50123456789:9:50123456800
2399 -50123456789:9:-50123456800
2400 +501234500:6:501235000
2401 -501234500:6:-501235000
2402 #+501234500:-4:501235000
2403 #-501234500:-4:-501235000
2404 +12345000:4:12350000
2405 -12345000:4:-12350000
2407 +60123456789:5:60123000000
2408 -60123456789:5:-60123000000
2409 +60123456789:9:60123456800
2410 -60123456789:9:-60123456800
2411 +601234500:6:601234000
2412 -601234500:6:-601234000
2413 #+601234500:-4:601234000
2414 #-601234500:-4:-601234000
2421 +12345000:4:12340000
2422 -12345000:4:-12340000
2423 $round_mode('common')
2424 +60123456789:5:60123000000
2425 +60123199999:5:60123000000
2426 +60123299999:5:60123000000
2427 +60123399999:5:60123000000
2428 +60123499999:5:60123000000
2429 +60123500000:5:60124000000
2430 +60123600000:5:60124000000
2431 +60123700000:5:60124000000
2432 +60123800000:5:60124000000
2433 +60123900000:5:60124000000
2434 -60123456789:5:-60123000000
2435 -60123199999:5:-60123000000
2436 -60123299999:5:-60123000000
2437 -60123399999:5:-60123000000
2438 -60123499999:5:-60123000000
2439 -60123500000:5:-60124000000
2440 -60123600000:5:-60124000000
2441 -60123700000:5:-60124000000
2442 -60123800000:5:-60124000000
2443 -60123900000:5:-60124000000
2461 # floor and ceil tests are pretty pointless in integer space...but play safe
2488 0x123456789123456789:0x123456789123456789
2498 0b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
2499 0x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001