1 #include this file into another for subclass testing
3 my $version = ${"$class\::VERSION"};
5 ##############################################################################
6 # for testing inheritance of _swap
10 use Math::BigInt lib => $main::CL;
12 @ISA = (qw/Math::BigInt/);
15 # customized overload for sub, since original does not use swap there
16 '-' => sub { my @a = ref($_[0])->_swap(@_);
21 # a fake _swap, which reverses the params
22 my $self = shift; # for override in subclass
25 my $c = ref ($_[0] ) || 'Math::Foo';
26 return ( $_[0]->copy(), $_[1] );
30 return ( Math::Foo->new($_[1]), $_[0] );
34 ##############################################################################
37 my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
39 my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
44 next if /^#/; # skip comments
51 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
54 @args = split(/:/,$_,99); $ans = pop(@args);
55 $expected_class = $class;
56 if ($ans =~ /(.*?)=(.*)/)
58 $expected_class = $2; $ans = $1;
60 $try = "\$x = $class->new(\"$args[0]\");";
63 $try = "\$x = $class->bnorm(\"$args[0]\");";
65 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
67 } elsif ($f eq "as_hex") {
68 $try .= '$x->as_hex();';
69 } elsif ($f eq "as_bin") {
70 $try .= '$x->as_bin();';
71 } elsif ($f eq "is_inf") {
72 $try .= "\$x->is_inf('$args[1]');";
73 } elsif ($f eq "binf") {
74 $try .= "\$x->binf('$args[1]');";
75 } elsif ($f eq "bone") {
76 $try .= "\$x->bone('$args[1]');";
78 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
80 } elsif ($f eq "length") {
81 $try .= '$x->length();';
82 } elsif ($f eq "exponent"){
83 # ->bstr() to see if an object is returned
84 $try .= '$x = $x->exponent()->bstr();';
85 } elsif ($f eq "mantissa"){
86 # ->bstr() to see if an object is returned
87 $try .= '$x = $x->mantissa()->bstr();';
88 } elsif ($f eq "parts"){
89 $try .= '($m,$e) = $x->parts();';
90 # ->bstr() to see if an object is returned
91 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
92 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
95 $try .= "\$y = $class->new('$args[1]');";
99 } elsif ($f eq "bround") {
100 $try .= "$round_mode; \$x->bround(\$y);";
101 } elsif ($f eq "bacmp"){
102 $try .= '$x->bacmp($y);';
103 } elsif ($f eq "badd"){
105 } elsif ($f eq "bsub"){
107 } elsif ($f eq "bmul"){
109 } elsif ($f eq "bdiv"){
111 } elsif ($f eq "bdiv-list"){
112 $try .= 'join (",",$x->bdiv($y));';
114 } elsif ($f =~ /^.=$/){
115 $try .= "\$x $f \$y;";
117 } elsif ($f =~ /^.$/){
118 $try .= "\$x $f \$y;";
119 } elsif ($f eq "bmod"){
121 } elsif ($f eq "bgcd")
123 if (defined $args[2])
125 $try .= " \$z = $class->new('$args[2]'); ";
127 $try .= "$class\::bgcd(\$x, \$y";
128 $try .= ", \$z" if (defined $args[2]);
133 if (defined $args[2])
135 $try .= " \$z = $class->new('$args[2]'); ";
137 $try .= "$class\::blcm(\$x, \$y";
138 $try .= ", \$z" if (defined $args[2]);
140 }elsif ($f eq "blsft"){
141 if (defined $args[2])
143 $try .= "\$x->blsft(\$y,$args[2]);";
147 $try .= "\$x << \$y;";
149 }elsif ($f eq "brsft"){
150 if (defined $args[2])
152 $try .= "\$x->brsft(\$y,$args[2]);";
156 $try .= "\$x >> \$y;";
158 }elsif ($f eq "band"){
159 $try .= "\$x & \$y;";
160 }elsif ($f eq "bior"){
161 $try .= "\$x | \$y;";
162 }elsif ($f eq "bxor"){
163 $try .= "\$x ^ \$y;";
164 }elsif ($f eq "bpow"){
165 $try .= "\$x ** \$y;";
166 } elsif( $f eq "bmodinv") {
167 $try .= "\$x->bmodinv(\$y);";
168 }elsif ($f eq "digit"){
169 $try .= "\$x->digit(\$y);";
171 $try .= "\$z = $class->new(\"$args[2]\");";
173 # Functions with three arguments
174 if( $f eq "bmodpow") {
175 $try .= "\$x->bmodpow(\$y,\$z);";
176 } else { warn "Unknown op '$f'"; }
178 } # end else all other ops
181 # convert hex/binary targets to decimal
182 if ($ans =~ /^(0x0x|0b0b)/)
184 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
192 # print "try: $try ans: $ans1 $ans\n";
193 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
194 ok (ref($ans),$expected_class) if $expected_class ne $class;
196 # check internal state of number objects
197 is_valid($ans1,$f) if ref $ans1;
198 } # endwhile data tests
203 for (my $i = 1; $i < 10; $i++)
207 ok "@a", "1 2 3 4 5 6 7 8 9";
209 # test whether self-multiplication works correctly (result is 2**64)
210 $try = "\$x = $class->new('4294967296');";
211 $try .= '$a = $x->bmul($x);';
213 print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
215 $try = "\$x = $class->new(10);";
216 $try .= '$a = $x->bpow($x);';
218 print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
220 # test whether op destroys args or not (should better not)
246 $x = $class->new(-5); $y = -$x;
249 $x = $class->new(-5); $y = abs($x);
252 # check whether overloading cmp works
253 $try = "\$x = $class->new(0);";
255 $try .= "'false' if \$x ne \$y;";
257 print "# For '$try'\n" if (!ok "$ans" , "false" );
259 # we cant test for working cmpt with other objects here, we would need a dummy
260 # object with stringify overload for this. see Math::String tests as example
262 ###############################################################################
263 # check reversed order of arguments
265 $try = "\$x = $class->new(10); \$x = 2 ** \$x;";
266 $try .= "'ok' if \$x == 1024;"; $ans = eval $try;
267 print "# For '$try'\n" if (!ok "$ans" , "ok" );
269 $try = "\$x = $class->new(10); \$x = 2 * \$x;";
270 $try .= "'ok' if \$x == 20;"; $ans = eval $try;
271 print "# For '$try'\n" if (!ok "$ans" , "ok" );
273 $try = "\$x = $class->new(10); \$x = 2 + \$x;";
274 $try .= "'ok' if \$x == 12;"; $ans = eval $try;
275 print "# For '$try'\n" if (!ok "$ans" , "ok" );
277 $try = "\$x = $class\->new(10); \$x = 2 - \$x;";
278 $try .= "'ok' if \$x == -8;"; $ans = eval $try;
279 print "# For '$try'\n" if (!ok "$ans" , "ok" );
281 $try = "\$x = $class\->new(10); \$x = 20 / \$x;";
282 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
283 print "# For '$try'\n" if (!ok "$ans" , "ok" );
285 $try = "\$x = $class\->new(3); \$x = 20 % \$x;";
286 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
287 print "# For '$try'\n" if (!ok "$ans" , "ok" );
289 $try = "\$x = $class\->new(7); \$x = 20 & \$x;";
290 $try .= "'ok' if \$x == 4;"; $ans = eval $try;
291 print "# For '$try'\n" if (!ok "$ans" , "ok" );
293 $try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
294 $try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
295 print "# For '$try'\n" if (!ok "$ans" , "ok" );
297 $try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
298 $try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
299 print "# For '$try'\n" if (!ok "$ans" , "ok" );
301 ###############################################################################
302 # check badd(4,5) form
304 $try = "\$x = $class\->badd(4,5);";
305 $try .= "'ok' if \$x == 9;";
307 print "# For '$try'\n" if (!ok "$ans" , "ok" );
309 ###############################################################################
310 # check undefs: NOT DONE YET
312 ###############################################################################
315 $x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
316 $x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
318 ###############################################################################
321 @args = Math::BigInt::objectify(2,4,5);
322 ok (scalar @args,3); # $class, 4, 5
323 ok ($args[0] =~ /^Math::BigInt/);
327 @args = Math::BigInt::objectify(0,4,5);
328 ok (scalar @args,3); # $class, 4, 5
329 ok ($args[0] =~ /^Math::BigInt/);
333 @args = Math::BigInt::objectify(2,4,5);
334 ok (scalar @args,3); # $class, 4, 5
335 ok ($args[0] =~ /^Math::BigInt/);
339 @args = Math::BigInt::objectify(2,4,5,6,7);
340 ok (scalar @args,5); # $class, 4, 5, 6, 7
341 ok ($args[0] =~ /^Math::BigInt/);
342 ok ($args[1],4); ok (ref($args[1]),$args[0]);
343 ok ($args[2],5); ok (ref($args[2]),$args[0]);
344 ok ($args[3],6); ok (ref($args[3]),'');
345 ok ($args[4],7); ok (ref($args[4]),'');
347 @args = Math::BigInt::objectify(2,$class,4,5,6,7);
348 ok (scalar @args,5); # $class, 4, 5, 6, 7
349 ok ($args[0],$class);
350 ok ($args[1],4); ok (ref($args[1]),$args[0]);
351 ok ($args[2],5); ok (ref($args[2]),$args[0]);
352 ok ($args[3],6); ok (ref($args[3]),'');
353 ok ($args[4],7); ok (ref($args[4]),'');
355 ###############################################################################
356 # test for floating-point input (other tests in bnorm() below)
358 $z = 1050000000000000; # may be int on systems with 64bit?
359 $x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
360 $z = 1e+129; # definitely a float (may fail on UTS)
361 # don't compare to $z, since some Perl versions stringify $z into something
362 # like '1.e+129' or something equally ugly
363 $x = $class->new($z); ok ($x->bsstr(),'1e+129');
365 ###############################################################################
366 # prime number tests, also test for **= and length()
367 # found on: http://www.utm.edu/research/primes/notes/by_year.html
370 $x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
371 ok ($x,"20988936657440586486151264256610222593863921");
372 ok ($x->length(),length "20988936657440586486151264256610222593863921");
375 $x = $class->new(2); $x **= 127; $x--;
376 ok ($x,"170141183460469231731687303715884105727");
378 $x = $class->new('215960156869840440586892398248');
379 ($x,$y) = $x->length();
380 ok ($x,30); ok ($y,0);
382 $x = $class->new('1_000_000_000_000');
383 ($x,$y) = $x->length();
384 ok ($x,13); ok ($y,0);
386 # I am afraid the following is not yet possible due to slowness
387 # Also, testing for 2 meg output is a bit hard ;)
388 #$x = $class->new(2); $x **= 6972593; $x--;
390 # 593573509*2^332162+1 has exactly 1,000,000 digits
391 # takes about 24 mins on 300 Mhz, so cannot be done yet ;)
392 #$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
393 #ok ($x->length(),1_000_000);
395 ###############################################################################
396 # inheritance and overriding of _swap
398 $x = Math::Foo->new(5);
399 $x = $x - 8; # 8 - 5 instead of 5-8
401 ok (ref($x),'Math::Foo');
403 $x = Math::Foo->new(5);
404 $x = 8 - $x; # 5 - 8 instead of 8 - 5
406 ok (ref($x),'Math::Foo');
408 ###############################################################################
409 # Test whether +inf eq inf
410 # This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
411 # hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
412 # like 1e100000 crash on some platforms. So simple test for the string 'inf'
413 $x = $class->new('+inf'); ok ($x,'inf');
415 ###############################################################################
416 ###############################################################################
417 # the followin tests only make sense with Math::BigInt::Calc or BareCalc
419 exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
421 ###############################################################################
422 # check proper length of internal arrays
424 my $bl = $CL->_base_len();
425 my $BASE = '9' x $bl;
429 $x = $class->new($MAX); is_valid($x); # f.i. 9999
430 $x += 1; ok ($x,$BASE); is_valid($x); # 10000
431 $x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
433 ###############################################################################
436 $x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
437 $x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
439 # +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
440 $x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
441 $x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
442 $x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
443 ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
445 ###############################################################################
446 # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
448 $x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
449 if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
451 $x = $class->new($BASE+3); $x++;
452 if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
454 # test for +0 instead of int():
455 $x = $class->new($MAX); ok ($x->length(), length($MAX));
457 ###############################################################################
458 # test bug that $class->digit($string) did not work
460 ok ($class->digit(123,2),1);
462 ###############################################################################
463 # bug in sub where number with at least 6 trailing zeros after any op failed
465 $x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
469 ###############################################################################
470 # bug in shortcut in mul()
472 # construct a number with a zero-hole of BASE_LEN_SMALL
474 my @bl = $CL->_base_len(); my $bl = $bl[4];
476 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
478 $x = $class->new($x)->bmul($y);
479 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
481 for (my $i = 1; $i <= $bl; $i++)
483 $y .= $i; $d = $i.$d;
485 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
489 ###############################################################################
490 # see if mul shortcut for small numbers works
493 $x = $class->new($x);
494 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
495 ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
499 ###############################################################################
500 # bug with rest "-0" in div, causing further div()s to fail
502 $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
504 ok ($y,'0'); is_valid($y); # $y not '-0'
506 ###############################################################################
507 # bone/binf etc as plain calls (Lite failed them)
509 ok ($class->bzero(),0);
510 ok ($class->bone(),1);
511 ok ($class->bone('+'),1);
512 ok ($class->bone('-'),-1);
513 ok ($class->bnan(),'NaN');
514 ok ($class->binf(),'inf');
515 ok ($class->binf('+'),'inf');
516 ok ($class->binf('-'),'-inf');
517 ok ($class->binf('-inf'),'-inf');
519 ###############################################################################
524 ###############################################################################
525 ###############################################################################
526 # Perl 5.005 does not like ok ($x,undef)
532 ok (1,1) and return if !defined $x;
536 ###############################################################################
537 # sub to check validity of a BigInt internally, to ensure that no op leaves a
538 # number object in an invalid state (f.i. "-0")
546 # allow the check to pass for all Lite, and all MBI and subclasses
548 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
550 if (ref($x) ne 'Math::BigInt::Lite')
553 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
554 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
556 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
557 $e = $CALC->_check($x->{value}) if $e eq '0';
560 # test done, see if error did crop up
561 ok (1,1), return if ($e eq '0');
563 ok (1,$e." after op '$f'");
642 -123456789:+987654321:-1
643 +123456789:-987654321:-1
644 +987654321:+123456789:1
645 -987654321:+123456789:1
687 0b10000000000001:8193
688 0b100000000000001:16385
689 0b1000000000000001:32769
690 0b10000000000000001:65537
691 0b100000000000000001:131073
692 0b1000000000000000001:262145
693 0b10000000000000000001:524289
694 0b100000000000000000001:1048577
695 0b1000000000000000000001:2097153
696 0b10000000000000000000001:4194305
697 0b100000000000000000000001:8388609
698 0b1000000000000000000000001:16777217
699 0b10000000000000000000000001:33554433
700 0b100000000000000000000000001:67108865
701 0b1000000000000000000000000001:134217729
702 0b10000000000000000000000000001:268435457
703 0b100000000000000000000000000001:536870913
704 0b1000000000000000000000000000001:1073741825
705 0b10000000000000000000000000000001:2147483649
706 0b100000000000000000000000000000001:4294967297
707 0b1000000000000000000000000000000001:8589934593
708 0b10000000000000000000000000000000001:17179869185
720 0x1_2_3_4_56_78:305419896
721 0xa_b_c_d_e_f:11259375
750 0x40000001:1073741825
751 0x80000001:2147483649
752 0x100000001:4294967297
753 0x200000001:8589934593
754 0x400000001:17179869185
755 0x800000001:34359738369
769 # only one underscore between two digits
787 # bug with two E's in number beeing valid
800 01234567891:1234567891
801 012345678912:12345678912
802 0123456789123:123456789123
803 01234567891234:1234567891234
820 -123456789:-123456789
829 # floating point input
837 # non-integer numbers
876 # it must be exactly /^[+-]inf$/
883 +1:+48:281474976710656
886 +12345:4:10:123450000
892 1234567890123:12:10:1234567890123000000000000
896 -102533203:1:2:-205066406
901 +281474976710656:+48:1
912 1230000000000:10:10:123
913 09876123456789067890:12:10:9876123
914 1234561234567890123:13:10:123456
915 820265627:1:2:410132813
916 # test shifting negative numbers in base 2
932 -1640531254:2:2:-410132814
933 -1640531254:1:2:-820265627
934 -820265627:1:2:-410132814
935 -205066405:1:2:-102533203
949 +123456789:-123456789
984 -123456789:987654321:-1
985 +123456789:-987654321:1
986 -987654321:123456789:-1
1045 +9999999:+1:10000000
1046 +99999999:+1:100000000
1047 +999999999:+1:1000000000
1048 +9999999999:+1:10000000000
1049 +99999999999:+1:100000000000
1056 +10000000:-1:9999999
1057 +100000000:-1:99999999
1058 +1000000000:-1:999999999
1059 +10000000000:-1:9999999999
1060 +123456789:987654321:1111111110
1061 -123456789:987654321:864197532
1062 -123456789:-987654321:-1111111110
1063 +123456789:-987654321:-864197532
1067 -1:10000001:10000000
1068 -1:100000001:100000000
1069 -1:1000000001:1000000000
1070 -1:10000000001:10000000000
1071 -1:100000000001:100000000000
1072 -1:1000000000001:1000000000000
1073 -1:10000000000001:10000000000000
1076 -1:-1000001:-1000002
1077 -1:-10000001:-10000002
1078 -1:-100000001:-100000002
1079 -1:-1000000001:-1000000002
1080 -1:-10000000001:-10000000002
1081 -1:-100000000001:-100000000002
1082 -1:-1000000000001:-1000000000002
1083 -1:-10000000000001:-10000000000002
1108 +99999999:+1:99999998
1109 +999999999:+1:999999998
1110 +9999999999:+1:9999999998
1111 +99999999999:+1:99999999998
1118 +10000000:-1:10000001
1119 +100000000:-1:100000001
1120 +1000000000:-1:1000000001
1121 +10000000000:-1:10000000001
1122 +123456789:+987654321:-864197532
1123 -123456789:+987654321:-1111111110
1124 -123456789:-987654321:864197532
1125 +123456789:-987654321:1111111110
1130 100000001:1:100000000
1131 1000000001:1:1000000000
1132 10000000001:1:10000000000
1133 100000000001:1:100000000000
1134 1000000000001:1:1000000000000
1135 10000000000001:1:10000000000000
1139 10000001:-1:10000002
1140 100000001:-1:100000002
1141 1000000001:-1:1000000002
1142 10000000001:-1:10000000002
1143 100000000001:-1:100000000002
1144 1000000000001:-1:1000000000002
1145 10000000000001:-1:10000000000002
1163 123456789123456789:0:0
1164 0:123456789123456789:0
1174 10101:10101:102030201
1175 1001001:1001001:1002003002001
1176 100010001:100010001:10002000300020001
1177 10000100001:10000100001:100002000030000200001
1178 11111111111:9:99999999999
1179 22222222222:9:199999999998
1180 33333333333:9:299999999997
1181 44444444444:9:399999999996
1182 55555555555:9:499999999995
1183 66666666666:9:599999999994
1184 77777777777:9:699999999993
1185 88888888888:9:799999999992
1186 99999999999:9:899999999991
1188 +12345:+12345:152399025
1189 +99999:+11111:1111088889
1191 99999:100000:9999900000
1192 999999:1000000:999999000000
1193 9999999:10000000:99999990000000
1194 99999999:100000000:9999999900000000
1195 999999999:1000000000:999999999000000000
1196 9999999999:10000000000:99999999990000000000
1197 99999999999:100000000000:9999999999900000000000
1198 999999999999:1000000000000:999999999999000000000000
1199 9999999999999:10000000000000:99999999999990000000000000
1200 99999999999999:100000000000000:9999999999999900000000000000
1201 999999999999999:1000000000000000:999999999999999000000000000000
1202 9999999999999999:10000000000000000:99999999999999990000000000000000
1203 99999999999999999:100000000000000000:9999999999999999900000000000000000
1204 999999999999999999:1000000000000000000:999999999999999999000000000000000000
1205 9999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1215 # inf handling and general remainder
1221 # see table in documentation in MBI
1240 # exceptions to reminder rule
1249 # inf handling (see table in doc)
1284 1000000000:9:111111111
1285 2000000000:9:222222222
1286 3000000000:9:333333333
1287 4000000000:9:444444444
1288 5000000000:9:555555555
1289 6000000000:9:666666666
1290 7000000000:9:777777777
1291 8000000000:9:888888888
1292 9000000000:9:1000000000
1295 106500000:339:314159
1296 1000000000:3:333333333
1301 999999999999:9:111111111111
1302 999999999999:99:10101010101
1303 999999999999:999:1001001001
1304 999999999999:9999:100010001
1305 999999999999999:99999:10000100001
1306 +1111088889:99999:11111
1321 # bug in Calc with '99999' vs $BASE-1
1322 10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1324 ## format: number:modulus:result
1325 ## bmodinv Data errors
1329 ## bmodinv Expected Results from normal use
1333 #324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
1334 ## bmodinv Error cases / useless use of function
1338 ## format: number:exponent:modulus:result
1339 ## bmodpow Data errors
1347 ## bmodpow Expected results
1353 #98436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1354 ## bmodpow Error cases
1360 # inf handling, see table in doc
1379 # exceptions to reminder rule
1418 999999999999999:99999:0
1432 152403346:12345:4321
1434 # test shortcuts in Calc
1435 # 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
1442 1234567891234567:9:1
1443 123456789123456789:9:0
1450 1234567891234567:10:7
1451 123456789123456789:10:9
1457 12345678912345:113:53
1458 1234567891234567:113:56
1459 123456789123456789:113:39
1492 +281474976710656:0:0
1493 +281474976710656:1:0
1494 +281474976710656:+281474976710656:281474976710656
1501 # equal arguments are treated special, so also do some test with unequal ones
1502 0xFFFF:0xFFFF:0x0xFFFF
1503 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1504 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1505 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1506 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1507 0xF0F0:0xF0F0:0x0xF0F0
1508 0x0F0F:0x0F0F:0x0x0F0F
1509 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1510 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1511 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1512 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1513 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1514 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1515 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1516 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1517 0x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
1524 +281474976710656:0:281474976710656
1525 +281474976710656:1:281474976710657
1526 +281474976710656:281474976710656:281474976710656
1532 # equal arguments are treated special, so also do some test with unequal ones
1533 0xFFFF:0xFFFF:0x0xFFFF
1534 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1535 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1536 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1537 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1539 0:0xFFFFFF:0x0xFFFFFF
1540 0:0xFFFFFFFF:0x0xFFFFFFFF
1541 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1542 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1544 0xFFFFFF:0:0x0xFFFFFF
1545 0xFFFFFFFF:0:0x0xFFFFFFFF
1546 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
1547 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
1548 0xF0F0:0xF0F0:0x0xF0F0
1549 0x0F0F:0x0F0F:0x0x0F0F
1550 0xF0F0:0x0F0F:0x0xFFFF
1551 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1552 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1553 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
1554 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1555 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1556 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
1557 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1558 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1559 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
1560 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1561 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1562 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1563 0x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1570 +281474976710656:0:281474976710656
1571 +281474976710656:1:281474976710657
1572 +281474976710656:281474976710656:0
1580 # equal arguments are treated special, so also do some test with unequal ones
1583 0xFFFFFFFF:0xFFFFFFFF:0
1584 0xFFFFFFFFFF:0xFFFFFFFFFF:0
1585 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
1587 0:0xFFFFFF:0x0xFFFFFF
1588 0:0xFFFFFFFF:0x0xFFFFFFFF
1589 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1590 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1592 0xFFFFFF:0:0x0xFFFFFF
1593 0xFFFFFFFF:0:0x0xFFFFFFFF
1594 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
1595 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
1598 0xF0F0:0x0F0F:0x0xFFFF
1601 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
1602 0xF0F0F0F0:0xF0F0F0F0:0
1603 0x0F0F0F0F:0x0F0F0F0F:0
1604 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
1605 0xF0F0F0F0F0:0xF0F0F0F0F0:0
1606 0x0F0F0F0F0F:0x0F0F0F0F0F:0
1607 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
1608 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
1609 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
1610 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1615 +281474976710656:-281474976710657
1710 -inf:1234500012:-inf
1711 +inf:-12345000123:inf
1712 -inf:-12345000123:-inf
1713 # 1 ** -x => 1 / (1 ** x)
1733 10:20:100000000000000000000
1734 123456:2:15241383936
1741 10000000000000000:17
1743 215960156869840440586892398248:30
1759 4000000000000:2000000
1770 $round_mode('trunc')
1780 +10123456789:5:10123000000
1781 -10123456789:5:-10123000000
1782 +10123456789:9:10123456700
1783 -10123456789:9:-10123456700
1784 +101234500:6:101234000
1785 -101234500:6:-101234000
1786 #+101234500:-4:101234000
1787 #-101234500:-4:-101234000
1789 +20123456789:5:20123000000
1790 -20123456789:5:-20123000000
1791 +20123456789:9:20123456800
1792 -20123456789:9:-20123456800
1793 +201234500:6:201234000
1794 -201234500:6:-201234000
1795 #+201234500:-4:201234000
1796 #-201234500:-4:-201234000
1797 +12345000:4:12340000
1798 -12345000:4:-12340000
1800 +30123456789:5:30123000000
1801 -30123456789:5:-30123000000
1802 +30123456789:9:30123456800
1803 -30123456789:9:-30123456800
1804 +301234500:6:301235000
1805 -301234500:6:-301234000
1806 #+301234500:-4:301235000
1807 #-301234500:-4:-301234000
1808 +12345000:4:12350000
1809 -12345000:4:-12340000
1811 +40123456789:5:40123000000
1812 -40123456789:5:-40123000000
1813 +40123456789:9:40123456800
1814 -40123456789:9:-40123456800
1815 +401234500:6:401234000
1816 +401234500:6:401234000
1817 #-401234500:-4:-401235000
1818 #-401234500:-4:-401235000
1819 +12345000:4:12340000
1820 -12345000:4:-12350000
1822 +50123456789:5:50123000000
1823 -50123456789:5:-50123000000
1824 +50123456789:9:50123456800
1825 -50123456789:9:-50123456800
1826 +501234500:6:501235000
1827 -501234500:6:-501235000
1828 #+501234500:-4:501235000
1829 #-501234500:-4:-501235000
1830 +12345000:4:12350000
1831 -12345000:4:-12350000
1833 +60123456789:5:60123000000
1834 -60123456789:5:-60123000000
1835 +60123456789:9:60123456800
1836 -60123456789:9:-60123456800
1837 +601234500:6:601234000
1838 -601234500:6:-601234000
1839 #+601234500:-4:601234000
1840 #-601234500:-4:-601234000
1847 +12345000:4:12340000
1848 -12345000:4:-12340000
1866 # floor and ceil tests are pretty pointless in integer space...but play safe
1893 0x123456789123456789:0x123456789123456789
1903 0b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101