10 unshift @INC, '../lib'; # for running manually
13 my $version = '1.40'; # for $VERSION tests, match current release (by hand!)
15 ##############################################################################
16 # for testing inheritance of _swap
21 #use Math::BigInt lib => 'BitVect'; # for testing
23 @ISA = (qw/Math::BigInt/);
26 # customized overload for sub, since original does not use swap there
27 '-' => sub { my @a = ref($_[0])->_swap(@_);
32 # a fake _swap, which reverses the params
33 my $self = shift; # for override in subclass
36 my $c = ref ($_[0] ) || 'Math::Foo';
37 return ( $_[0]->copy(), $_[1] );
41 return ( Math::Foo->new($_[1]), $_[0] );
45 ##############################################################################
49 #use Math::BigInt lib => 'BitVect'; # for testing
51 my $CALC = Math::BigInt::_core_lib(); ok ($CALC,'Math::BigInt::Calc');
53 my (@args,$f,$try,$x,$y,$z,$a,$exp,$ans,$ans1,@a,$m,$e,$round_mode);
58 next if /^#/; # skip comments
66 $round_mode =~ s/^\$/Math::BigInt->/;
67 # print "$round_mode\n";
71 @args = split(/:/,$_,99);
73 $try = "\$x = Math::BigInt->new(\"$args[0]\");";
76 } elsif ($f eq "is_zero") {
77 $try .= '$x->is_zero()+0;';
78 } elsif ($f eq "is_one") {
79 $try .= '$x->is_one()+0;';
80 } elsif ($f eq "is_odd") {
81 $try .= '$x->is_odd()+0;';
82 } elsif ($f eq "is_even") {
83 $try .= '$x->is_even()+0;';
84 } elsif ($f eq "is_negative") {
85 $try .= '$x->is_negative()+0;';
86 } elsif ($f eq "is_positive") {
87 $try .= '$x->is_positive()+0;';
88 } elsif ($f eq "is_inf") {
89 $try .= "\$x->is_inf('$args[1]')+0;";
90 } elsif ($f eq "binf") {
91 $try .= "\$x->binf('$args[1]');";
92 } elsif ($f eq "bone") {
93 $try .= "\$x->bone('$args[1]');";
94 } elsif ($f eq "bnan") {
95 $try .= "\$x->bnan();";
96 } elsif ($f eq "bfloor") {
97 $try .= '$x->bfloor();';
98 } elsif ($f eq "bceil") {
99 $try .= '$x->bceil();';
100 } elsif ($f eq "bsstr") {
101 $try .= '$x->bsstr();';
102 } elsif ($f eq "bneg") {
103 $try .= '$x->bneg();';
104 } elsif ($f eq "babs") {
105 $try .= '$x->babs();';
106 } elsif ($f eq "binc") {
108 } elsif ($f eq "bdec") {
110 }elsif ($f eq "bnot") {
112 }elsif ($f eq "bsqrt") {
113 $try .= '$x->bsqrt();';
114 }elsif ($f eq "length") {
115 $try .= "\$x->length();";
116 }elsif ($f eq "exponent"){
117 $try .= '$x = $x->exponent()->bstr();';
118 }elsif ($f eq "mantissa"){
119 $try .= '$x = $x->mantissa()->bstr();';
120 }elsif ($f eq "parts"){
121 $try .= "(\$m,\$e) = \$x->parts();";
122 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
123 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
126 $try .= "\$y = new Math::BigInt ('$args[1]');";
128 $try .= '$x <=> $y;';
129 }elsif ($f eq "bround") {
130 $try .= "$round_mode; \$x->bround(\$y);";
131 }elsif ($f eq "bacmp"){
132 $try .= "\$x->bacmp(\$y);";
133 }elsif ($f eq "badd"){
134 $try .= "\$x + \$y;";
135 }elsif ($f eq "bsub"){
136 $try .= "\$x - \$y;";
137 }elsif ($f eq "bmul"){
138 $try .= "\$x * \$y;";
139 }elsif ($f eq "bdiv"){
140 $try .= "\$x / \$y;";
141 }elsif ($f eq "bdiv-list"){
142 $try .= 'join (",",$x->bdiv($y));';
143 }elsif ($f eq "bmod"){
144 $try .= "\$x % \$y;";
145 }elsif ($f eq "bgcd")
147 if (defined $args[2])
149 $try .= " \$z = new Math::BigInt \"$args[2]\"; ";
151 $try .= "Math::BigInt::bgcd(\$x, \$y";
152 $try .= ", \$z" if (defined $args[2]);
157 if (defined $args[2])
159 $try .= " \$z = new Math::BigInt \"$args[2]\"; ";
161 $try .= "Math::BigInt::blcm(\$x, \$y";
162 $try .= ", \$z" if (defined $args[2]);
164 }elsif ($f eq "blsft"){
165 if (defined $args[2])
167 $try .= "\$x->blsft(\$y,$args[2]);";
171 $try .= "\$x << \$y;";
173 }elsif ($f eq "brsft"){
174 if (defined $args[2])
176 $try .= "\$x->brsft(\$y,$args[2]);";
180 $try .= "\$x >> \$y;";
182 }elsif ($f eq "band"){
183 $try .= "\$x & \$y;";
184 }elsif ($f eq "bior"){
185 $try .= "\$x | \$y;";
186 }elsif ($f eq "bxor"){
187 $try .= "\$x ^ \$y;";
188 }elsif ($f eq "bpow"){
189 $try .= "\$x ** \$y;";
190 }elsif ($f eq "digit"){
191 $try = "\$x = Math::BigInt->new(\"$args[0]\"); \$x->digit($args[1]);";
192 } else { warn "Unknown op '$f'"; }
194 # print "trying $try\n";
196 $ans =~ s/^[+]([0-9])/$1/; # remove leading '+'
203 #print "try: $try ans: $ans1 $ans\n";
204 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
206 # check internal state of number objects
207 is_valid($ans1,$f) if ref $ans1;
209 } # endwhile data tests
212 # XXX Tels 06/29/2001 following tests never fail or do not work :( !?
214 # test whether use Math::BigInt qw/version/ works
215 $try = "use Math::BigInt ($version.'1');";
216 $try .= ' $x = Math::BigInt->new(123); $x = "$x";';
218 ok_undef ( $_ ); # should result in error!
220 # test whether constant works or not, also test for qw($version)
221 $try = "use Math::BigInt ($version,'babs',':constant');";
222 $try .= ' $x = 2**150; babs($x); $x = "$x";';
224 ok ( $ans1, "1427247692705959881058285969449495136382746624");
226 # test wether Math::BigInt::Small via use works (w/ dff. spellings of calc)
227 #$try = "use Math::BigInt ($version,'lib','Small');";
228 #$try .= ' $x = 2**10; $x = "$x";';
230 #ok ( $ans1, "1024");
231 #$try = "use Math::BigInt ($version,'LiB','Math::BigInt::Small');";
232 #$try .= ' $x = 2**10; $x = "$x";';
234 #ok ( $ans1, "1024");
235 # test wether calc => undef (array element not existing) works
236 #$try = "use Math::BigInt ($version,'LIB');";
237 #$try = "require Math::BigInt; Math::BigInt::import($version,'CALC');";
238 #$try .= ' $x = Math::BigInt->new(2)**10; $x = "$x";';
242 # test whether fallback to calc works
243 $try = "use Math::BigInt ($version,'lib','foo, bar , ');";
244 $try .= ' Math::BigInt::_core_lib();';
246 ok ( $ans1, "Math::BigInt::Calc");
250 for (my $i = 1; $i < 10; $i++)
254 ok "@a", "1 2 3 4 5 6 7 8 9";
256 # test whether self-multiplication works correctly (result is 2**64)
257 $try = '$x = new Math::BigInt "+4294967296";';
258 $try .= '$a = $x->bmul($x);';
260 print "# Tried: '$try'\n" if !ok ($ans1, Math::BigInt->new(2) ** 64);
262 $try = '$x = Math::BigInt->new(10);';
263 $try .= '$a = $x->bpow($x);';
265 print "# Tried: '$try'\n" if !ok ($ans1, Math::BigInt->new(10) ** 10);
267 # test whether op destroys args or not (should better not)
269 $x = new Math::BigInt (3);
270 $y = new Math::BigInt (4);
279 $x = new Math::BigInt (1);
280 $y = new Math::BigInt (2);
286 $x = new Math::BigInt (5);
287 $y = new Math::BigInt (4);
293 $x = new Math::BigInt (-5); $y = -$x;
296 $x = new Math::BigInt (-5); $y = abs($x);
299 # check whether overloading cmp works
300 $try = "\$x = Math::BigInt->new(0);";
302 $try .= "'false' if \$x ne \$y;";
304 print "# For '$try'\n" if (!ok "$ans" , "false" );
306 # we cant test for working cmpt with other objects here, we would need a dummy
307 # object with stringify overload for this. see Math::String tests
309 ###############################################################################
311 $try = "\$x = Math::BigInt->new(1); \$x += 9;";
312 $try .= "'ok' if \$x == 10;";
314 print "# For '$try'\n" if (!ok "$ans" , "ok" );
316 $try = "\$x = Math::BigInt->new(1); \$x -= 9;";
317 $try .= "'ok' if \$x == -8;";
319 print "# For '$try'\n" if (!ok "$ans" , "ok" );
321 $try = "\$x = Math::BigInt->new(1); \$x *= 9;";
322 $try .= "'ok' if \$x == 9;";
324 print "# For '$try'\n" if (!ok "$ans" , "ok" );
326 $try = "\$x = Math::BigInt->new(10); \$x /= 2;";
327 $try .= "'ok' if \$x == 5;";
329 print "# For '$try'\n" if (!ok "$ans" , "ok" );
331 ###############################################################################
332 # check reversed order of arguments
333 $try = "\$x = Math::BigInt->new(10); \$x = 2 ** \$x;";
334 $try .= "'ok' if \$x == 1024;"; $ans = eval $try;
335 print "# For '$try'\n" if (!ok "$ans" , "ok" );
337 $try = "\$x = Math::BigInt->new(10); \$x = 2 * \$x;";
338 $try .= "'ok' if \$x == 20;"; $ans = eval $try;
339 print "# For '$try'\n" if (!ok "$ans" , "ok" );
341 $try = "\$x = Math::BigInt->new(10); \$x = 2 + \$x;";
342 $try .= "'ok' if \$x == 12;"; $ans = eval $try;
343 print "# For '$try'\n" if (!ok "$ans" , "ok" );
345 $try = "\$x = Math::BigInt->new(10); \$x = 2 - \$x;";
346 $try .= "'ok' if \$x == -8;"; $ans = eval $try;
347 print "# For '$try'\n" if (!ok "$ans" , "ok" );
349 $try = "\$x = Math::BigInt->new(10); \$x = 20 / \$x;";
350 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
351 print "# For '$try'\n" if (!ok "$ans" , "ok" );
353 ###############################################################################
354 # check badd(4,5) form
356 $try = "\$x = Math::BigInt::badd(4,5);";
357 $try .= "'ok' if \$x == 9;";
359 print "# For '$try'\n" if (!ok "$ans" , "ok" );
361 $try = "\$x = Math::BigInt->badd(4,5);";
362 $try .= "'ok' if \$x == 9;";
364 print "# For '$try'\n" if (!ok "$ans" , "ok" );
366 ###############################################################################
367 # the followin tests only make sense with Math::BigInt::Calc
369 ###############################################################################
370 # check proper length of internal arrays
372 $x = Math::BigInt->new(99999); is_valid($x);
373 $x += 1; ok ($x,100000); is_valid($x);
374 $x -= 1; ok ($x,99999); is_valid($x);
376 ###############################################################################
379 my $BASE = int(1e5); # should access Math::BigInt::Calc::BASE
380 $x = Math::BigInt->new($BASE-1); ok ($x->numify(),$BASE-1);
381 $x = Math::BigInt->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
382 $x = Math::BigInt->new($BASE); ok ($x->numify(),$BASE);
383 $x = Math::BigInt->new(-$BASE); ok ($x->numify(),-$BASE);
384 $x = Math::BigInt->new( -($BASE*$BASE*1+$BASE*1+1) );
385 ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
387 ###############################################################################
388 # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
390 $x = Math::BigInt->new(99998); $x++; $x++; $x++; $x++;
391 if ($x > 100000) { ok (1,1) } else { ok ("$x < 100000","$x > 100000"); }
393 $x = Math::BigInt->new(100003); $x++;
394 $y = Math::BigInt->new(1000000);
395 if ($x < 1000000) { ok (1,1) } else { ok ("$x > 1000000","$x < 1000000"); }
397 ###############################################################################
398 # bug in sub where number with at least 6 trailing zeros after any op failed
400 $x = Math::BigInt->new(123456); $z = Math::BigInt->new(10000); $z *= 10;
405 ###############################################################################
406 # bug in shortcut in mul()
408 # construct a number with a zero-hole of BASE_LEN
409 my $bl = Math::BigInt::Calc::_base_len();
410 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
413 $x = Math::BigInt->new($x)->bmul($y);
414 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
416 for (my $i = 1; $i <= $bl; $i++)
418 $y .= $i; $d = $i.$d;
421 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
424 ###############################################################################
425 # bug with rest "-0" in div, causing further div()s to fail
427 $x = Math::BigInt->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
429 ok ($y,'0','not -0'); # not '-0'
432 ###############################################################################
433 # check undefs: NOT DONE YET
435 ###############################################################################
438 $x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
439 $x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
441 ###############################################################################
444 @args = Math::BigInt::objectify(2,4,5);
445 ok (scalar @args,3); # 'Math::BigInt', 4, 5
446 ok ($args[0],'Math::BigInt');
450 @args = Math::BigInt::objectify(0,4,5);
451 ok (scalar @args,3); # 'Math::BigInt', 4, 5
452 ok ($args[0],'Math::BigInt');
456 @args = Math::BigInt::objectify(2,4,5);
457 ok (scalar @args,3); # 'Math::BigInt', 4, 5
458 ok ($args[0],'Math::BigInt');
462 @args = Math::BigInt::objectify(2,4,5,6,7);
463 ok (scalar @args,5); # 'Math::BigInt', 4, 5, 6, 7
464 ok ($args[0],'Math::BigInt');
465 ok ($args[1],4); ok (ref($args[1]),$args[0]);
466 ok ($args[2],5); ok (ref($args[2]),$args[0]);
467 ok ($args[3],6); ok (ref($args[3]),'');
468 ok ($args[4],7); ok (ref($args[4]),'');
470 @args = Math::BigInt::objectify(2,'Math::BigInt',4,5,6,7);
471 ok (scalar @args,5); # 'Math::BigInt', 4, 5, 6, 7
472 ok ($args[0],'Math::BigInt');
473 ok ($args[1],4); ok (ref($args[1]),$args[0]);
474 ok ($args[2],5); ok (ref($args[2]),$args[0]);
475 ok ($args[3],6); ok (ref($args[3]),'');
476 ok ($args[4],7); ok (ref($args[4]),'');
478 ###############################################################################
479 # test for floating-point input (other tests in bnorm() below)
481 $z = 1050000000000000; # may be int on systems with 64bit?
482 $x = Math::BigInt->new($z); ok ($x->bsstr(),'105e+13'); # not 1.03e+15
483 $z = 1e+129; # definitely a float (may fail on UTS)
484 $x = Math::BigInt->new($z); ok ($x->bsstr(),$z);
486 ###############################################################################
487 # prime number tests, also test for **= and length()
488 # found on: http://www.utm.edu/research/primes/notes/by_year.html
491 $x = Math::BigInt->new(2); $x **= 148; $x++; $x = $x / 17;
492 ok ($x,"20988936657440586486151264256610222593863921");
493 ok ($x->length(),length "20988936657440586486151264256610222593863921");
496 $x = Math::BigInt->new(2); $x **= 127; $x--;
497 ok ($x,"170141183460469231731687303715884105727");
499 # I am afraid the following is not yet possible due to slowness
500 # Also, testing for 2 meg output is a bit hard ;)
501 #$x = new Math::BigInt(2); $x **= 6972593; $x--;
503 # 593573509*2^332162+1 has exactly 1,000,000 digits
504 # takes about 24 mins on 300 Mhz, so cannot be done yet ;)
505 #$x = Math::BigInt->new(2); $x **= 332162; $x *= "593573509"; $x++;
506 #ok ($x->length(),1_000_000);
508 ###############################################################################
509 # inheritance and overriding of _swap
511 $x = Math::Foo->new(5);
512 $x = $x - 8; # 8 - 5 instead of 5-8
514 ok (ref($x),'Math::Foo');
516 $x = Math::Foo->new(5);
517 $x = 8 - $x; # 5 - 8 instead of 8 - 5
519 ok (ref($x),'Math::Foo');
521 ###############################################################################
522 # test whether +inf eq inf
524 $y = 1e1000000; # create inf, since bareword inf does not work
525 $x = Math::BigInt->new('+inf'); ok_inf ($x,$y);
527 ###############################################################################
530 ###############################################################################
532 # libc are confused what to call Infinity
535 $_[0] =~ s/^(inf(?:inity)?|\+\+)$/Inf/i; # HP-UX calls it "++"
547 # Perl 5.005 does not like ok ($x,undef)
553 ok (1,1) and return if !defined $x;
557 ###############################################################################
558 # sub to check validity of a BigInt internally, to ensure that no op leaves a
559 # number object in an invalid state (f.i. "-0")
567 $e = 'Not a reference to Math::BigInt' if !ref($x);
570 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
571 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
573 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
574 $e = $CALC->_check($x->{value}) if $e eq '0';
576 # test done, see if error did crop up
577 ok (1,1), return if ($e eq '0');
579 ok (1,$e." op '$f'");
624 -123456789:+987654321:-1
625 +123456789:-987654321:-1
626 +987654321:+123456789:1
627 -987654321:+123456789:1
659 0b1000000000000000000000000000000:1073741824
670 0x1_2_3_4_56_78:305419896
699 -123456789:-123456789
716 # floating point input
751 # it must be exactly /^[+-]inf$/
758 +1:+48:+281474976710656
761 +12345:4:10:123450000
767 1234567890123:12:10:1234567890123000000000000
772 +281474976710656:+48:+1
783 1230000000000:10:10:123
784 09876123456789067890:12:10:9876123
785 1234561234567890123:13:10:123456
799 +123456789:-123456789
800 -123456789:+123456789
808 +123456789:+123456789
809 -123456789:+123456789
834 -123456789:+987654321:-1
835 +123456789:-987654321:1
836 -987654321:+123456789:-1
891 +9999999:+1:+10000000
892 +99999999:+1:+100000000
893 +999999999:+1:+1000000000
894 +9999999999:+1:+10000000000
895 +99999999999:+1:+100000000000
902 +10000000:-1:+9999999
903 +100000000:-1:+99999999
904 +1000000000:-1:+999999999
905 +10000000000:-1:+9999999999
906 +123456789:+987654321:+1111111110
907 -123456789:+987654321:+864197532
908 -123456789:-987654321:-1111111110
909 +123456789:-987654321:-864197532
934 +99999999:+1:+99999998
935 +999999999:+1:+999999998
936 +9999999999:+1:+9999999998
937 +99999999999:+1:+99999999998
944 +10000000:-1:+10000001
945 +100000000:-1:+100000001
946 +1000000000:-1:+1000000001
947 +10000000000:-1:+10000000001
948 +123456789:+987654321:-864197532
949 -123456789:+987654321:-1111111110
950 -123456789:-987654321:+864197532
951 +123456789:-987654321:+1111111110
969 +123456789123456789:+0:+0
970 +0:+123456789123456789:+0
980 +10101:+10101:+102030201
981 +1001001:+1001001:+1002003002001
982 +100010001:+100010001:+10002000300020001
983 +10000100001:+10000100001:+100002000030000200001
984 +11111111111:+9:+99999999999
985 +22222222222:+9:+199999999998
986 +33333333333:+9:+299999999997
987 +44444444444:+9:+399999999996
988 +55555555555:+9:+499999999995
989 +66666666666:+9:+599999999994
990 +77777777777:+9:+699999999993
991 +88888888888:+9:+799999999992
992 +99999999999:+9:+899999999991
994 +12345:+12345:+152399025
995 +99999:+11111:+1111088889
1020 +1000000000:+9:+111111111
1021 +2000000000:+9:+222222222
1022 +3000000000:+9:+333333333
1023 +4000000000:+9:+444444444
1024 +5000000000:+9:+555555555
1025 +6000000000:+9:+666666666
1026 +7000000000:+9:+777777777
1027 +8000000000:+9:+888888888
1028 +9000000000:+9:+1000000000
1029 +35500000:+113:+314159
1030 +71000000:+226:+314159
1031 +106500000:+339:+314159
1032 +1000000000:+3:+333333333
1037 +999999999999:+9:+111111111111
1038 +999999999999:+99:+10101010101
1039 +999999999999:+999:+1001001001
1040 +999999999999:+9999:+100010001
1041 +999999999999999:+99999:+10000100001
1042 +1111088889:+99999:+11111
1086 +999999999999:+99:+0
1087 +999999999999:+999:+0
1088 +999999999999:+9999:+0
1089 +999999999999999:+99999:+0
1134 +281474976710656:+0:+0
1135 +281474976710656:+1:+0
1136 +281474976710656:+281474976710656:+281474976710656
1149 +281474976710656:+0:+281474976710656
1150 +281474976710656:+1:+281474976710657
1151 +281474976710656:+281474976710656:+281474976710656
1163 +281474976710656:+0:+281474976710656
1164 +281474976710656:+1:+281474976710657
1165 +281474976710656:+281474976710656:+0
1177 +281474976710656:-281474976710657
1251 -inf:1234500012:-inf
1252 +inf:-12345000123:inf
1253 -inf:-12345000123:-inf
1254 # 1 ** -x => 1 / (1 ** x)
1274 10:20:100000000000000000000
1275 123456:2:15241383936
1282 10000000000000000:17
1292 4000000000000:2000000
1298 $round_mode('trunc')
1308 +10123456789:5:+10123000000
1309 -10123456789:5:-10123000000
1310 +10123456789:9:+10123456700
1311 -10123456789:9:-10123456700
1312 +101234500:6:+101234000
1313 -101234500:6:-101234000
1314 #+101234500:-4:+101234000
1315 #-101234500:-4:-101234000
1317 +20123456789:5:+20123000000
1318 -20123456789:5:-20123000000
1319 +20123456789:9:+20123456800
1320 -20123456789:9:-20123456800
1321 +201234500:6:+201234000
1322 -201234500:6:-201234000
1323 #+201234500:-4:+201234000
1324 #-201234500:-4:-201234000
1325 +12345000:4:12340000
1326 -12345000:4:-12340000
1328 +30123456789:5:+30123000000
1329 -30123456789:5:-30123000000
1330 +30123456789:9:+30123456800
1331 -30123456789:9:-30123456800
1332 +301234500:6:+301235000
1333 -301234500:6:-301234000
1334 #+301234500:-4:+301235000
1335 #-301234500:-4:-301234000
1336 +12345000:4:12350000
1337 -12345000:4:-12340000
1339 +40123456789:5:+40123000000
1340 -40123456789:5:-40123000000
1341 +40123456789:9:+40123456800
1342 -40123456789:9:-40123456800
1343 +401234500:6:+401234000
1344 +401234500:6:+401234000
1345 #-401234500:-4:-401235000
1346 #-401234500:-4:-401235000
1347 +12345000:4:12340000
1348 -12345000:4:-12350000
1350 +50123456789:5:+50123000000
1351 -50123456789:5:-50123000000
1352 +50123456789:9:+50123456800
1353 -50123456789:9:-50123456800
1354 +501234500:6:+501235000
1355 -501234500:6:-501235000
1356 #+501234500:-4:+501235000
1357 #-501234500:-4:-501235000
1358 +12345000:4:12350000
1359 -12345000:4:-12350000
1361 +60123456789:5:+60123000000
1362 -60123456789:5:-60123000000
1363 +60123456789:9:+60123456800
1364 -60123456789:9:-60123456800
1365 +601234500:6:+601234000
1366 -601234500:6:-601234000
1367 #+601234500:-4:+601234000
1368 #-601234500:-4:-601234000
1375 +12345000:4:12340000
1376 -12345000:4:-12340000
1394 # floor and ceil tests are pretty pointless in integer space...but play safe