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
523 # This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
524 # hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
525 # like 1e100000 crash on some platforms. So simple test for 'inf'
526 $x = Math::BigInt->new('+inf'); ok ($x,'inf');
528 ###############################################################################
531 ###############################################################################
532 # Perl 5.005 does not like ok ($x,undef)
538 ok (1,1) and return if !defined $x;
542 ###############################################################################
543 # sub to check validity of a BigInt internally, to ensure that no op leaves a
544 # number object in an invalid state (f.i. "-0")
552 $e = 'Not a reference to Math::BigInt' if !ref($x);
555 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
556 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
558 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
559 $e = $CALC->_check($x->{value}) if $e eq '0';
561 # test done, see if error did crop up
562 ok (1,1), return if ($e eq '0');
564 ok (1,$e." op '$f'");
609 -123456789:+987654321:-1
610 +123456789:-987654321:-1
611 +987654321:+123456789:1
612 -987654321:+123456789:1
644 0b1000000000000000000000000000000:1073741824
655 0x1_2_3_4_56_78:305419896
684 -123456789:-123456789
701 # floating point input
736 # it must be exactly /^[+-]inf$/
743 +1:+48:+281474976710656
746 +12345:4:10:123450000
752 1234567890123:12:10:1234567890123000000000000
757 +281474976710656:+48:+1
768 1230000000000:10:10:123
769 09876123456789067890:12:10:9876123
770 1234561234567890123:13:10:123456
784 +123456789:-123456789
785 -123456789:+123456789
793 +123456789:+123456789
794 -123456789:+123456789
819 -123456789:+987654321:-1
820 +123456789:-987654321:1
821 -987654321:+123456789:-1
876 +9999999:+1:+10000000
877 +99999999:+1:+100000000
878 +999999999:+1:+1000000000
879 +9999999999:+1:+10000000000
880 +99999999999:+1:+100000000000
887 +10000000:-1:+9999999
888 +100000000:-1:+99999999
889 +1000000000:-1:+999999999
890 +10000000000:-1:+9999999999
891 +123456789:+987654321:+1111111110
892 -123456789:+987654321:+864197532
893 -123456789:-987654321:-1111111110
894 +123456789:-987654321:-864197532
919 +99999999:+1:+99999998
920 +999999999:+1:+999999998
921 +9999999999:+1:+9999999998
922 +99999999999:+1:+99999999998
929 +10000000:-1:+10000001
930 +100000000:-1:+100000001
931 +1000000000:-1:+1000000001
932 +10000000000:-1:+10000000001
933 +123456789:+987654321:-864197532
934 -123456789:+987654321:-1111111110
935 -123456789:-987654321:+864197532
936 +123456789:-987654321:+1111111110
954 +123456789123456789:+0:+0
955 +0:+123456789123456789:+0
965 +10101:+10101:+102030201
966 +1001001:+1001001:+1002003002001
967 +100010001:+100010001:+10002000300020001
968 +10000100001:+10000100001:+100002000030000200001
969 +11111111111:+9:+99999999999
970 +22222222222:+9:+199999999998
971 +33333333333:+9:+299999999997
972 +44444444444:+9:+399999999996
973 +55555555555:+9:+499999999995
974 +66666666666:+9:+599999999994
975 +77777777777:+9:+699999999993
976 +88888888888:+9:+799999999992
977 +99999999999:+9:+899999999991
979 +12345:+12345:+152399025
980 +99999:+11111:+1111088889
1005 +1000000000:+9:+111111111
1006 +2000000000:+9:+222222222
1007 +3000000000:+9:+333333333
1008 +4000000000:+9:+444444444
1009 +5000000000:+9:+555555555
1010 +6000000000:+9:+666666666
1011 +7000000000:+9:+777777777
1012 +8000000000:+9:+888888888
1013 +9000000000:+9:+1000000000
1014 +35500000:+113:+314159
1015 +71000000:+226:+314159
1016 +106500000:+339:+314159
1017 +1000000000:+3:+333333333
1022 +999999999999:+9:+111111111111
1023 +999999999999:+99:+10101010101
1024 +999999999999:+999:+1001001001
1025 +999999999999:+9999:+100010001
1026 +999999999999999:+99999:+10000100001
1027 +1111088889:+99999:+11111
1071 +999999999999:+99:+0
1072 +999999999999:+999:+0
1073 +999999999999:+9999:+0
1074 +999999999999999:+99999:+0
1119 +281474976710656:+0:+0
1120 +281474976710656:+1:+0
1121 +281474976710656:+281474976710656:+281474976710656
1134 +281474976710656:+0:+281474976710656
1135 +281474976710656:+1:+281474976710657
1136 +281474976710656:+281474976710656:+281474976710656
1148 +281474976710656:+0:+281474976710656
1149 +281474976710656:+1:+281474976710657
1150 +281474976710656:+281474976710656:+0
1162 +281474976710656:-281474976710657
1236 -inf:1234500012:-inf
1237 +inf:-12345000123:inf
1238 -inf:-12345000123:-inf
1239 # 1 ** -x => 1 / (1 ** x)
1259 10:20:100000000000000000000
1260 123456:2:15241383936
1267 10000000000000000:17
1277 4000000000000:2000000
1283 $round_mode('trunc')
1293 +10123456789:5:+10123000000
1294 -10123456789:5:-10123000000
1295 +10123456789:9:+10123456700
1296 -10123456789:9:-10123456700
1297 +101234500:6:+101234000
1298 -101234500:6:-101234000
1299 #+101234500:-4:+101234000
1300 #-101234500:-4:-101234000
1302 +20123456789:5:+20123000000
1303 -20123456789:5:-20123000000
1304 +20123456789:9:+20123456800
1305 -20123456789:9:-20123456800
1306 +201234500:6:+201234000
1307 -201234500:6:-201234000
1308 #+201234500:-4:+201234000
1309 #-201234500:-4:-201234000
1310 +12345000:4:12340000
1311 -12345000:4:-12340000
1313 +30123456789:5:+30123000000
1314 -30123456789:5:-30123000000
1315 +30123456789:9:+30123456800
1316 -30123456789:9:-30123456800
1317 +301234500:6:+301235000
1318 -301234500:6:-301234000
1319 #+301234500:-4:+301235000
1320 #-301234500:-4:-301234000
1321 +12345000:4:12350000
1322 -12345000:4:-12340000
1324 +40123456789:5:+40123000000
1325 -40123456789:5:-40123000000
1326 +40123456789:9:+40123456800
1327 -40123456789:9:-40123456800
1328 +401234500:6:+401234000
1329 +401234500:6:+401234000
1330 #-401234500:-4:-401235000
1331 #-401234500:-4:-401235000
1332 +12345000:4:12340000
1333 -12345000:4:-12350000
1335 +50123456789:5:+50123000000
1336 -50123456789:5:-50123000000
1337 +50123456789:9:+50123456800
1338 -50123456789:9:-50123456800
1339 +501234500:6:+501235000
1340 -501234500:6:-501235000
1341 #+501234500:-4:+501235000
1342 #-501234500:-4:-501235000
1343 +12345000:4:12350000
1344 -12345000:4:-12350000
1346 +60123456789:5:+60123000000
1347 -60123456789:5:-60123000000
1348 +60123456789:9:+60123456800
1349 -60123456789:9:-60123456800
1350 +601234500:6:+601234000
1351 -601234500:6:-601234000
1352 #+601234500:-4:+601234000
1353 #-601234500:-4:-601234000
1360 +12345000:4:12340000
1361 -12345000:4:-12340000
1379 # floor and ceil tests are pretty pointless in integer space...but play safe