assorted VMS test fix-ups, $Config{prefixexp} revisited
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigintpm.inc
CommitLineData
6854fd01 1#include this file into another for subclass testing
2
3my $version = ${"$class\::VERSION"};
4
5##############################################################################
6# for testing inheritance of _swap
7
8package Math::Foo;
9
61f5c3f5 10use Math::BigInt lib => $main::CL;
6854fd01 11use vars qw/@ISA/;
12@ISA = (qw/Math::BigInt/);
13
14use overload
15# customized overload for sub, since original does not use swap there
16'-' => sub { my @a = ref($_[0])->_swap(@_);
17 $a[0]->bsub($a[1])};
18
19sub _swap
20 {
21 # a fake _swap, which reverses the params
22 my $self = shift; # for override in subclass
23 if ($_[2])
24 {
25 my $c = ref ($_[0] ) || 'Math::Foo';
26 return ( $_[0]->copy(), $_[1] );
27 }
28 else
29 {
30 return ( Math::Foo->new($_[1]), $_[0] );
31 }
32 }
33
34##############################################################################
35package main;
36
b3abae2a 37my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
6854fd01 38
b3abae2a 39my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
6854fd01 40
41while (<DATA>)
42 {
43 chop;
44 next if /^#/; # skip comments
45 if (s/^&//)
46 {
61f5c3f5 47 $f = $_; next;
6854fd01 48 }
49 elsif (/^\$/)
50 {
61f5c3f5 51 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
6854fd01 52 }
61f5c3f5 53
54 @args = split(/:/,$_,99); $ans = pop(@args);
b3abae2a 55 $expected_class = $class;
56 if ($ans =~ /(.*?)=(.*)/)
57 {
58 $expected_class = $2; $ans = $1;
59 }
61f5c3f5 60 $try = "\$x = $class->new(\"$args[0]\");";
61 if ($f eq "bnorm")
6854fd01 62 {
61f5c3f5 63 $try = "\$x = $class->bnorm(\"$args[0]\");";
64 # some is_xxx tests
b3abae2a 65 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
61f5c3f5 66 $try .= "\$x->$f();";
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]');";
77 # some unary ops
b3abae2a 78 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
61f5c3f5 79 $try .= "\$x->$f();";
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;';
93 $try .= '"$m,$e";';
94 } else {
95 $try .= "\$y = $class->new('$args[1]');";
96 if ($f eq "bcmp")
97 {
98 $try .= '$x <=> $y;';
99 } elsif ($f eq "bround") {
6854fd01 100 $try .= "$round_mode; \$x->bround(\$y);";
61f5c3f5 101 } elsif ($f eq "bacmp"){
102 $try .= '$x->bacmp($y);';
103 } elsif ($f eq "badd"){
104 $try .= '$x + $y;';
105 } elsif ($f eq "bsub"){
106 $try .= '$x - $y;';
107 } elsif ($f eq "bmul"){
108 $try .= '$x * $y;';
109 } elsif ($f eq "bdiv"){
110 $try .= '$x / $y;';
111 } elsif ($f eq "bdiv-list"){
112 $try .= 'join (",",$x->bdiv($y));';
027dc388 113 # overload via x=
61f5c3f5 114 } elsif ($f =~ /^.=$/){
115 $try .= "\$x $f \$y;";
027dc388 116 # overload via x
61f5c3f5 117 } elsif ($f =~ /^.$/){
118 $try .= "\$x $f \$y;";
119 } elsif ($f eq "bmod"){
120 $try .= '$x % $y;';
121 } elsif ($f eq "bgcd")
6854fd01 122 {
123 if (defined $args[2])
124 {
61f5c3f5 125 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 126 }
127 $try .= "$class\::bgcd(\$x, \$y";
128 $try .= ", \$z" if (defined $args[2]);
129 $try .= " );";
130 }
131 elsif ($f eq "blcm")
132 {
133 if (defined $args[2])
134 {
61f5c3f5 135 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 136 }
137 $try .= "$class\::blcm(\$x, \$y";
138 $try .= ", \$z" if (defined $args[2]);
139 $try .= " );";
140 }elsif ($f eq "blsft"){
141 if (defined $args[2])
142 {
143 $try .= "\$x->blsft(\$y,$args[2]);";
144 }
145 else
146 {
147 $try .= "\$x << \$y;";
148 }
149 }elsif ($f eq "brsft"){
150 if (defined $args[2])
151 {
152 $try .= "\$x->brsft(\$y,$args[2]);";
153 }
154 else
155 {
156 $try .= "\$x >> \$y;";
157 }
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 "digit"){
61f5c3f5 167 $try = "\$x = $class->new('$args[0]'); \$x->digit($args[1]);";
6854fd01 168 } else { warn "Unknown op '$f'"; }
61f5c3f5 169 } # end else all other ops
170
171 $ans1 = eval $try;
172 # convert hex/binary targets to decimal
173 if ($ans =~ /^(0x0x|0b0b)/)
174 {
175 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 176 }
61f5c3f5 177 if ($ans eq "")
178 {
179 ok_undef ($ans1);
180 }
181 else
182 {
183 # print "try: $try ans: $ans1 $ans\n";
184 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
b3abae2a 185 ok (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 186 }
61f5c3f5 187 # check internal state of number objects
188 is_valid($ans1,$f) if ref $ans1;
6854fd01 189 } # endwhile data tests
190close DATA;
191
192# test some more
193@a = ();
194for (my $i = 1; $i < 10; $i++)
195 {
196 push @a, $i;
197 }
198ok "@a", "1 2 3 4 5 6 7 8 9";
199
200# test whether self-multiplication works correctly (result is 2**64)
201$try = "\$x = $class->new('4294967296');";
202$try .= '$a = $x->bmul($x);';
203$ans1 = eval $try;
204print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
205# test self-pow
206$try = "\$x = $class->new(10);";
207$try .= '$a = $x->bpow($x);';
208$ans1 = eval $try;
209print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
210
211# test whether op destroys args or not (should better not)
212
213$x = $class->new(3);
214$y = $class->new(4);
215$z = $x & $y;
216ok ($x,3);
217ok ($y,4);
218ok ($z,0);
219$z = $x | $y;
220ok ($x,3);
221ok ($y,4);
222ok ($z,7);
223$x = $class->new(1);
224$y = $class->new(2);
225$z = $x | $y;
226ok ($x,1);
227ok ($y,2);
228ok ($z,3);
229
230$x = $class->new(5);
231$y = $class->new(4);
232$z = $x ^ $y;
233ok ($x,5);
234ok ($y,4);
235ok ($z,1);
236
237$x = $class->new(-5); $y = -$x;
238ok ($x, -5);
239
240$x = $class->new(-5); $y = abs($x);
241ok ($x, -5);
242
243# check whether overloading cmp works
244$try = "\$x = $class->new(0);";
245$try .= "\$y = 10;";
246$try .= "'false' if \$x ne \$y;";
247$ans = eval $try;
248print "# For '$try'\n" if (!ok "$ans" , "false" );
249
250# we cant test for working cmpt with other objects here, we would need a dummy
251# object with stringify overload for this. see Math::String tests as example
252
253###############################################################################
6854fd01 254# check reversed order of arguments
027dc388 255
6854fd01 256$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
257$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
258print "# For '$try'\n" if (!ok "$ans" , "ok" );
259
260$try = "\$x = $class->new(10); \$x = 2 * \$x;";
261$try .= "'ok' if \$x == 20;"; $ans = eval $try;
262print "# For '$try'\n" if (!ok "$ans" , "ok" );
263
264$try = "\$x = $class->new(10); \$x = 2 + \$x;";
265$try .= "'ok' if \$x == 12;"; $ans = eval $try;
266print "# For '$try'\n" if (!ok "$ans" , "ok" );
267
268$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
269$try .= "'ok' if \$x == -8;"; $ans = eval $try;
270print "# For '$try'\n" if (!ok "$ans" , "ok" );
271
272$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
273$try .= "'ok' if \$x == 2;"; $ans = eval $try;
274print "# For '$try'\n" if (!ok "$ans" , "ok" );
275
027dc388 276$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
277$try .= "'ok' if \$x == 2;"; $ans = eval $try;
278print "# For '$try'\n" if (!ok "$ans" , "ok" );
279
280$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
281$try .= "'ok' if \$x == 4;"; $ans = eval $try;
282print "# For '$try'\n" if (!ok "$ans" , "ok" );
283
284$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
285$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
286print "# For '$try'\n" if (!ok "$ans" , "ok" );
287
288$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
289$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
290print "# For '$try'\n" if (!ok "$ans" , "ok" );
291
6854fd01 292###############################################################################
293# check badd(4,5) form
294
295$try = "\$x = $class\->badd(4,5);";
296$try .= "'ok' if \$x == 9;";
297$ans = eval $try;
298print "# For '$try'\n" if (!ok "$ans" , "ok" );
299
300###############################################################################
301# check undefs: NOT DONE YET
302
303###############################################################################
304# bool
305
306$x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
307$x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
308
309###############################################################################
310# objectify()
311
312@args = Math::BigInt::objectify(2,4,5);
313ok (scalar @args,3); # $class, 4, 5
314ok ($args[0],$class);
315ok ($args[1],4);
316ok ($args[2],5);
317
318@args = Math::BigInt::objectify(0,4,5);
319ok (scalar @args,3); # $class, 4, 5
320ok ($args[0],$class);
321ok ($args[1],4);
322ok ($args[2],5);
323
324@args = Math::BigInt::objectify(2,4,5);
325ok (scalar @args,3); # $class, 4, 5
326ok ($args[0],$class);
327ok ($args[1],4);
328ok ($args[2],5);
329
330@args = Math::BigInt::objectify(2,4,5,6,7);
331ok (scalar @args,5); # $class, 4, 5, 6, 7
332ok ($args[0],$class);
333ok ($args[1],4); ok (ref($args[1]),$args[0]);
334ok ($args[2],5); ok (ref($args[2]),$args[0]);
335ok ($args[3],6); ok (ref($args[3]),'');
336ok ($args[4],7); ok (ref($args[4]),'');
337
338@args = Math::BigInt::objectify(2,$class,4,5,6,7);
339ok (scalar @args,5); # $class, 4, 5, 6, 7
340ok ($args[0],$class);
341ok ($args[1],4); ok (ref($args[1]),$args[0]);
342ok ($args[2],5); ok (ref($args[2]),$args[0]);
343ok ($args[3],6); ok (ref($args[3]),'');
344ok ($args[4],7); ok (ref($args[4]),'');
345
346###############################################################################
347# test for floating-point input (other tests in bnorm() below)
348
349$z = 1050000000000000; # may be int on systems with 64bit?
350$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
351$z = 1e+129; # definitely a float (may fail on UTS)
352# don't compare to $z, since some Perl versions stringify $z into something
353# like '1.e+129' or something equally ugly
354$x = $class->new($z); ok ($x->bsstr(),'1e+129');
355
356###############################################################################
357# prime number tests, also test for **= and length()
358# found on: http://www.utm.edu/research/primes/notes/by_year.html
359
360# ((2^148)-1)/17
361$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
362ok ($x,"20988936657440586486151264256610222593863921");
363ok ($x->length(),length "20988936657440586486151264256610222593863921");
364
365# MM7 = 2^127-1
366$x = $class->new(2); $x **= 127; $x--;
367ok ($x,"170141183460469231731687303715884105727");
368
369$x = $class->new('215960156869840440586892398248');
370($x,$y) = $x->length();
371ok ($x,30); ok ($y,0);
372
373$x = $class->new('1_000_000_000_000');
374($x,$y) = $x->length();
375ok ($x,13); ok ($y,0);
376
377# I am afraid the following is not yet possible due to slowness
378# Also, testing for 2 meg output is a bit hard ;)
379#$x = $class->new(2); $x **= 6972593; $x--;
380
381# 593573509*2^332162+1 has exactly 1,000,000 digits
382# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
383#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
384#ok ($x->length(),1_000_000);
385
386###############################################################################
387# inheritance and overriding of _swap
388
389$x = Math::Foo->new(5);
390$x = $x - 8; # 8 - 5 instead of 5-8
391ok ($x,3);
392ok (ref($x),'Math::Foo');
393
394$x = Math::Foo->new(5);
395$x = 8 - $x; # 5 - 8 instead of 8 - 5
396ok ($x,-3);
397ok (ref($x),'Math::Foo');
398
399###############################################################################
400# Test whether +inf eq inf
401# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
402# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
403# like 1e100000 crash on some platforms. So simple test for the string 'inf'
404$x = $class->new('+inf'); ok ($x,'inf');
405
406###############################################################################
407###############################################################################
394e6ffb 408# the followin tests only make sense with Math::BigInt::Calc or BareCalc
6854fd01 409
394e6ffb 410exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
6854fd01 411
412###############################################################################
413# check proper length of internal arrays
414
394e6ffb 415my $bl = $CL->_base_len();
6854fd01 416my $BASE = '9' x $bl;
417my $MAX = $BASE;
418$BASE++;
419
420$x = $class->new($MAX); is_valid($x); # f.i. 9999
421$x += 1; ok ($x,$BASE); is_valid($x); # 10000
422$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
423
424###############################################################################
425# check numify
426
427$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
428$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
61f5c3f5 429
430# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
431$x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
6854fd01 432$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
433$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
434ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
435
436###############################################################################
437# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
438
394e6ffb 439$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
440if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
441
442$x = $class->new($BASE+3); $x++;
443if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 444
394e6ffb 445# test for +0 instead of int():
446$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 447
448###############################################################################
449# bug in sub where number with at least 6 trailing zeros after any op failed
450
394e6ffb 451$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 452ok ($z, 100000);
453ok ($x, 23456);
454
455###############################################################################
456# bug in shortcut in mul()
457
61f5c3f5 458# construct a number with a zero-hole of BASE_LEN_SMALL
459{
460 my @bl = $CL->_base_len(); my $bl = $bl[4];
461
462 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
463 $y = '1' x (2*$bl);
464 $x = $class->new($x)->bmul($y);
465 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
466 $y = ''; my $d = '';
467 for (my $i = 1; $i <= $bl; $i++)
468 {
469 $y .= $i; $d = $i.$d;
470 }
471 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
472 ok ($x,$y);
473
6854fd01 474
475###############################################################################
394e6ffb 476# see if mul shortcut for small numbers works
477
478$x = '9' x $bl;
479$x = $class->new($x);
480# 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
481ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
482
61f5c3f5 483 }
484
394e6ffb 485###############################################################################
6854fd01 486# bug with rest "-0" in div, causing further div()s to fail
487
394e6ffb 488$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 489
61f5c3f5 490ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 491
61f5c3f5 492# all tests done
6854fd01 493
4941;
495
496###############################################################################
61f5c3f5 497###############################################################################
6854fd01 498# Perl 5.005 does not like ok ($x,undef)
499
500sub ok_undef
501 {
502 my $x = shift;
503
504 ok (1,1) and return if !defined $x;
505 ok ($x,'undef');
506 }
507
508###############################################################################
509# sub to check validity of a BigInt internally, to ensure that no op leaves a
510# number object in an invalid state (f.i. "-0")
511
512sub is_valid
513 {
514 my ($x,$f) = @_;
515
516 my $e = 0; # error?
517 # ok as reference?
518 $e = 'Not a reference to Math::BigInt' if !ref($x);
519
520 # has ok sign?
521 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
522 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
523
524 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
525 $e = $CALC->_check($x->{value}) if $e eq '0';
526
527 # test done, see if error did crop up
528 ok (1,1), return if ($e eq '0');
529
027dc388 530 ok (1,$e." after op '$f'");
6854fd01 531 }
532
533__DATA__
027dc388 534&.=
5351234:-345:1234-345
536&+=
5371:2:3
538-1:-2:-3
539&-=
5401:2:-1
541-1:-2:1
542&*=
5432:3:6
544-1:5:-5
545&%=
546100:3:1
5478:9:8
548&/=
549100:3:33
550-8:2:-4
551&|=
5522:1:3
553&&=
5545:7:5
555&^=
5565:7:2
6854fd01 557&is_negative
5580:0
559-1:1
5601:0
561+inf:0
562-inf:1
563NaNneg:0
564&is_positive
5650:1
566-1:0
5671:1
568+inf:1
569-inf:0
570NaNneg:0
b3abae2a 571&is_int
572-inf:0
573+inf:0
574NaNis_int:0
5751:1
5760:1
577123e12:1
6854fd01 578&is_odd
579abc:0
5800:0
5811:1
5823:1
583-1:1
584-3:1
58510000001:1
58610000002:0
5872:0
b3abae2a 588120:0
589121:1
6854fd01 590&is_even
591abc:0
5920:1
5931:0
5943:0
595-1:0
596-3:0
59710000001:0
59810000002:1
5992:1
b3abae2a 600120:1
601121:0
6854fd01 602&bacmp
603+0:-0:0
604+0:+1:-1
605-1:+1:0
606+1:-1:0
607-1:+2:-1
608+2:-1:1
609-123456789:+987654321:-1
610+123456789:-987654321:-1
611+987654321:+123456789:1
612-987654321:+123456789:1
613-123:+4567889:-1
614# NaNs
615acmpNaN:123:
616123:acmpNaN:
617acmpNaN:acmpNaN:
618# infinity
619+inf:+inf:0
620-inf:-inf:0
621+inf:-inf:0
622-inf:+inf:0
623+inf:123:1
624-inf:123:1
625+inf:-123:1
626-inf:-123:1
627# return undef
628+inf:NaN:
629NaN:inf:
630-inf:NaN:
631NaN:-inf:
632&bnorm
633123:123
634# binary input
6350babc:NaN
6360b123:NaN
6370b0:0
638-0b0:0
639-0b1:-1
6400b0001:1
6410b001:1
6420b011:3
6430b101:5
61f5c3f5 6440b1001:9
6450b10001:17
6460b100001:33
6470b1000001:65
6480b10000001:129
6490b100000001:257
6500b1000000001:513
6510b10000000001:1025
6520b100000000001:2049
6530b1000000000001:4097
6540b10000000000001:8193
6550b100000000000001:16385
6560b1000000000000001:32769
6570b10000000000000001:65537
6580b100000000000000001:131073
6590b1000000000000000001:262145
6600b10000000000000000001:524289
6610b100000000000000000001:1048577
6620b1000000000000000000001:2097153
6630b10000000000000000000001:4194305
6640b100000000000000000000001:8388609
6650b1000000000000000000000001:16777217
6660b10000000000000000000000001:33554433
6670b100000000000000000000000001:67108865
6680b1000000000000000000000000001:134217729
6690b10000000000000000000000000001:268435457
6700b100000000000000000000000000001:536870913
6710b1000000000000000000000000000001:1073741825
6720b10000000000000000000000000000001:2147483649
6730b100000000000000000000000000000001:4294967297
6740b1000000000000000000000000000000001:8589934593
6750b10000000000000000000000000000000001:17179869185
6854fd01 6760b_101:NaN
6770b1_0_1:5
394e6ffb 6780b0_0_0_1:1
6854fd01 679# hex input
680-0x0:0
6810xabcdefgh:NaN
6820x1234:4660
6830xabcdef:11259375
684-0xABCDEF:-11259375
685-0x1234:-4660
6860x12345678:305419896
6870x1_2_3_4_56_78:305419896
394e6ffb 6880xa_b_c_d_e_f:11259375
6854fd01 6890x_123:NaN
61f5c3f5 6900x9:9
6910x11:17
6920x21:33
6930x41:65
6940x81:129
6950x101:257
6960x201:513
6970x401:1025
6980x801:2049
6990x1001:4097
7000x2001:8193
7010x4001:16385
7020x8001:32769
7030x10001:65537
7040x20001:131073
7050x40001:262145
7060x80001:524289
7070x100001:1048577
7080x200001:2097153
7090x400001:4194305
7100x800001:8388609
7110x1000001:16777217
7120x2000001:33554433
7130x4000001:67108865
7140x8000001:134217729
7150x10000001:268435457
7160x20000001:536870913
7170x40000001:1073741825
7180x80000001:2147483649
7190x100000001:4294967297
7200x200000001:8589934593
7210x400000001:17179869185
7220x800000001:34359738369
6854fd01 723# inf input
724inf:inf
725+inf:inf
726-inf:-inf
7270inf:NaN
027dc388 728# abnormal input
6854fd01 729:NaN
730abc:NaN
731 1 a:NaN
7321bcd2:NaN
73311111b:NaN
734+1z:NaN
735-1z:NaN
027dc388 736# only one underscore between two digits
737_123:NaN
738_123_:NaN
739123_:NaN
7401__23:NaN
7411E1__2:NaN
7421_E12:NaN
7431E_12:NaN
7441_E_12:NaN
745+_1E12:NaN
746+0_1E2:100
747+0_0_1E2:100
748-0_0_1E2:-100
749-0_0_1E+0_0_2:-100
750E1:NaN
751E23:NaN
7521.23E1:NaN
7531.23E-1:NaN
754# bug with two E's in number beeing valid
7551e2e3:NaN
7561e2r:NaN
7571e2.0:NaN
61f5c3f5 758# leading zeros
759012:12
7600123:123
76101234:1234
762012345:12345
7630123456:123456
76401234567:1234567
765012345678:12345678
7660123456789:123456789
76701234567891:1234567891
768012345678912:12345678912
7690123456789123:123456789123
77001234567891234:1234567891234
027dc388 771# normal input
6854fd01 7720:0
773+0:0
774+00:0
775+000:0
776000000000000000000:0
777-0:0
778-0000:0
779+1:1
780+01:1
781+001:1
782+00000100000:100000
783123456789:123456789
784-1:-1
785-01:-1
786-001:-1
787-123456789:-123456789
788-00000100000:-100000
7891_2_3:123
6854fd01 79010000000000E-1_0:1
7911E2:100
7921E1:10
7931E0:1
6854fd01 7941.23E2:123
6854fd01 795100E-1:10
796# floating point input
027dc388 797# .2e2:20
7981.E3:1000
6854fd01 7991.01E2:101
8001010E-1:101
801-1010E0:-1010
802-1010E1:-10100
027dc388 8031234.00:1234
804# non-integer numbers
6854fd01 805-1010E-2:NaN
806-1.01E+1:NaN
807-1.01E-1:NaN
6854fd01 808&bnan
8091:NaN
8102:NaN
811abc:NaN
812&bone
61f5c3f5 8132:+:1
6854fd01 8142:-:-1
815boneNaN:-:-1
61f5c3f5 816boneNaN:+:1
8172:abc:1
8183::1
6854fd01 819&binf
8201:+:inf
8212:-:-inf
8223:abc:inf
027dc388 823&is_nan
824123:0
825abc:1
826NaN:1
827-123:0
6854fd01 828&is_inf
829+inf::1
830-inf::1
831abc::0
8321::0
833NaN::0
834-1::0
835+inf:-:0
836+inf:+:1
837-inf:-:1
838-inf:+:0
839# it must be exactly /^[+-]inf$/
840+infinity::0
841-infinity::0
842&blsft
843abc:abc:NaN
61f5c3f5 844+2:+2:8
845+1:+32:4294967296
846+1:+48:281474976710656
6854fd01 847+8:-2:NaN
848# excercise base 10
849+12345:4:10:123450000
850-1234:0:10:-1234
61f5c3f5 851+1234:0:10:1234
6854fd01 852+2:2:10:200
853+12:2:10:1200
854+1234:-3:10:NaN
8551234567890123:12:10:1234567890123000000000000
b3abae2a 856-3:1:2:-6
857-5:1:2:-10
858-2:1:2:-4
859-102533203:1:2:-205066406
6854fd01 860&brsft
861abc:abc:NaN
61f5c3f5 862+8:+2:2
863+4294967296:+32:1
864+281474976710656:+48:1
6854fd01 865+2:-2:NaN
866# excercise base 10
867-1234:0:10:-1234
61f5c3f5 868+1234:0:10:1234
6854fd01 869+200:2:10:2
870+1234:3:10:1
871+1234:2:10:12
872+1234:-3:10:NaN
873310000:4:10:31
87412300000:5:10:123
8751230000000000:10:10:123
87609876123456789067890:12:10:9876123
8771234561234567890123:13:10:123456
b3abae2a 878820265627:1:2:410132813
879# test shifting negative numbers in base 2
880-15:1:2:-8
881-14:1:2:-7
882-13:1:2:-7
883-12:1:2:-6
884-11:1:2:-6
885-10:1:2:-5
886-9:1:2:-5
887-8:1:2:-4
888-7:1:2:-4
889-6:1:2:-3
890-5:1:2:-3
891-4:1:2:-2
892-3:1:2:-2
893-2:1:2:-1
894-1:1:2:-1
895-1640531254:2:2:-410132814
896-1640531254:1:2:-820265627
897-820265627:1:2:-410132814
898-205066405:1:2:-102533203
6854fd01 899&bsstr
9001e+34:1e+34
901123.456E3:123456e+0
902100:1e+2
903abc:NaN
904&bneg
905bnegNaN:NaN
906+inf:-inf
907-inf:inf
908abd:NaN
61f5c3f5 9090:0
9101:-1
911-1:1
6854fd01 912+123456789:-123456789
61f5c3f5 913-123456789:123456789
6854fd01 914&babs
915babsNaN:NaN
916+inf:inf
917-inf:inf
61f5c3f5 9180:0
9191:1
920-1:1
921+123456789:123456789
922-123456789:123456789
6854fd01 923&bcmp
924bcmpNaN:bcmpNaN:
61f5c3f5 925bcmpNaN:0:
9260:bcmpNaN:
9270:0:0
928-1:0:-1
9290:-1:1
9301:0:1
9310:1:-1
932-1:1:-1
9331:-1:1
6854fd01 934-1:-1:0
61f5c3f5 9351:1:0
936123:123:0
937123:12:1
93812:123:-1
6854fd01 939-123:-123:0
940-123:-12:-1
941-12:-123:1
61f5c3f5 942123:124:-1
943124:123:1
6854fd01 944-123:-124:1
945-124:-123:-1
61f5c3f5 946100:5:1
947-123456789:987654321:-1
6854fd01 948+123456789:-987654321:1
61f5c3f5 949-987654321:123456789:-1
6854fd01 950-inf:5432112345:-1
951+inf:5432112345:1
952-inf:-5432112345:-1
953+inf:-5432112345:1
954+inf:+inf:0
955-inf:-inf:0
956+inf:-inf:1
957-inf:+inf:-1
9585:inf:-1
9595:inf:-1
960-5:-inf:1
961-5:-inf:1
962# return undef
963+inf:NaN:
964NaN:inf:
965-inf:NaN:
966NaN:-inf:
967&binc
968abc:NaN
969+inf:inf
970-inf:-inf
61f5c3f5 971+0:1
972+1:2
973-1:0
6854fd01 974&bdec
975abc:NaN
976+inf:inf
977-inf:-inf
978+0:-1
61f5c3f5 979+1:0
6854fd01 980-1:-2
981&badd
982abc:abc:NaN
61f5c3f5 983abc:0:NaN
6854fd01 984+0:abc:NaN
b3abae2a 985+inf:-inf:NaN
986-inf:+inf:NaN
6854fd01 987+inf:+inf:inf
988-inf:-inf:-inf
989baddNaN:+inf:NaN
990baddNaN:+inf:NaN
991+inf:baddNaN:NaN
992-inf:baddNaN:NaN
61f5c3f5 9930:0:0
9941:0:1
9950:1:1
9961:1:2
997-1:0:-1
9980:-1:-1
6854fd01 999-1:-1:-2
61f5c3f5 1000-1:+1:0
1001+1:-1:0
1002+9:+1:10
1003+99:+1:100
1004+999:+1:1000
1005+9999:+1:10000
1006+99999:+1:100000
1007+999999:+1:1000000
1008+9999999:+1:10000000
1009+99999999:+1:100000000
1010+999999999:+1:1000000000
1011+9999999999:+1:10000000000
1012+99999999999:+1:100000000000
1013+10:-1:9
1014+100:-1:99
1015+1000:-1:999
1016+10000:-1:9999
1017+100000:-1:99999
1018+1000000:-1:999999
1019+10000000:-1:9999999
1020+100000000:-1:99999999
1021+1000000000:-1:999999999
1022+10000000000:-1:9999999999
1023+123456789:987654321:1111111110
1024-123456789:987654321:864197532
6854fd01 1025-123456789:-987654321:-1111111110
1026+123456789:-987654321:-864197532
1027&bsub
1028abc:abc:NaN
1029abc:+0:NaN
1030+0:abc:NaN
1031+inf:-inf:inf
1032-inf:+inf:-inf
b3abae2a 1033+inf:+inf:NaN
1034-inf:-inf:NaN
61f5c3f5 1035+0:+0:0
1036+1:+0:1
6854fd01 1037+0:+1:-1
61f5c3f5 1038+1:+1:0
6854fd01 1039-1:+0:-1
61f5c3f5 1040+0:-1:1
1041-1:-1:0
6854fd01 1042-1:+1:-2
61f5c3f5 1043+1:-1:2
1044+9:+1:8
1045+99:+1:98
1046+999:+1:998
1047+9999:+1:9998
1048+99999:+1:99998
1049+999999:+1:999998
1050+9999999:+1:9999998
1051+99999999:+1:99999998
1052+999999999:+1:999999998
1053+9999999999:+1:9999999998
1054+99999999999:+1:99999999998
1055+10:-1:11
1056+100:-1:101
1057+1000:-1:1001
1058+10000:-1:10001
1059+100000:-1:100001
1060+1000000:-1:1000001
1061+10000000:-1:10000001
1062+100000000:-1:100000001
1063+1000000000:-1:1000000001
1064+10000000000:-1:10000000001
6854fd01 1065+123456789:+987654321:-864197532
1066-123456789:+987654321:-1111111110
61f5c3f5 1067-123456789:-987654321:864197532
1068+123456789:-987654321:1111111110
6854fd01 1069&bmul
1070abc:abc:NaN
1071abc:+0:NaN
1072+0:abc:NaN
1073NaNmul:+inf:NaN
1074NaNmul:-inf:NaN
1075-inf:NaNmul:NaN
1076+inf:NaNmul:NaN
1077+inf:+inf:inf
1078+inf:-inf:-inf
1079-inf:+inf:-inf
1080-inf:-inf:inf
61f5c3f5 1081+0:+0:0
1082+0:+1:0
1083+1:+0:0
1084+0:-1:0
1085-1:+0:0
1086123456789123456789:0:0
10870:123456789123456789:0
1088-1:-1:1
6854fd01 1089-1:+1:-1
1090+1:-1:-1
61f5c3f5 1091+1:+1:1
1092+2:+3:6
6854fd01 1093-2:+3:-6
1094+2:-3:-6
61f5c3f5 1095-2:-3:6
1096111:111:12321
109710101:10101:102030201
10981001001:1001001:1002003002001
1099100010001:100010001:10002000300020001
110010000100001:10000100001:100002000030000200001
110111111111111:9:99999999999
110222222222222:9:199999999998
110333333333333:9:299999999997
110444444444444:9:399999999996
110555555555555:9:499999999995
110666666666666:9:599999999994
110777777777777:9:699999999993
110888888888888:9:799999999992
110999999999999:9:899999999991
1110+25:+25:625
1111+12345:+12345:152399025
1112+99999:+11111:1111088889
6854fd01 11139999:10000:99990000
111499999:100000:9999900000
1115999999:1000000:999999000000
11169999999:10000000:99999990000000
111799999999:100000000:9999999900000000
1118999999999:1000000000:999999999000000000
11199999999999:10000000000:99999999990000000000
112099999999999:100000000000:9999999999900000000000
1121999999999999:1000000000000:999999999999000000000000
11229999999999999:10000000000000:99999999999990000000000000
112399999999999999:100000000000000:9999999999999900000000000000
1124999999999999999:1000000000000000:999999999999999000000000000000
11259999999999999999:10000000000000000:99999999999999990000000000000000
112699999999999999999:100000000000000000:9999999999999999900000000000000000
1127999999999999999999:1000000000000000000:999999999999999999000000000000000000
11289999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1129&bdiv-list
1130100:20:5,0
11314095:4095:1,0
1132-4095:-4095:1,0
11334095:-4095:-1,0
1134-4095:4095:-1,0
1135123:2:61,1
b3abae2a 11369:5:1,4
11379:4:2,1
6854fd01 1138# inf handling and general remainder
11395:8:0,5
11400:8:0,0
114111:2:5,1
114211:-2:-5,-1
1143-11:2:-5,1
1144# see table in documentation in MBI
11450:inf:0,0
11460:-inf:0,0
11475:inf:0,5
11485:-inf:0,5
1149-5:inf:0,-5
1150-5:-inf:0,-5
1151inf:5:inf,0
1152-inf:5:-inf,0
1153inf:-5:-inf,0
1154-inf:-5:inf,0
11555:5:1,0
1156-5:-5:1,0
b3abae2a 1157inf:inf:NaN,NaN
1158-inf:-inf:NaN,NaN
1159-inf:inf:NaN,NaN
1160inf:-inf:NaN,NaN
6854fd01 11618:0:inf,8
1162inf:0:inf,inf
1163# exceptions to reminder rule
1164-8:0:-inf,-8
1165-inf:0:-inf,-inf
11660:0:NaN,NaN
1167&bdiv
1168abc:abc:NaN
61f5c3f5 1169abc:1:NaN
11701:abc:NaN
11710:0:NaN
6854fd01 1172# inf handling (see table in doc)
11730:inf:0
11740:-inf:0
11755:inf:0
11765:-inf:0
1177-5:inf:0
1178-5:-inf:0
1179inf:5:inf
1180-inf:5:-inf
1181inf:-5:-inf
1182-inf:-5:inf
11835:5:1
1184-5:-5:1
b3abae2a 1185inf:inf:NaN
1186-inf:-inf:NaN
1187-inf:inf:NaN
1188inf:-inf:NaN
6854fd01 11898:0:inf
1190inf:0:inf
1191-8:0:-inf
1192-inf:0:-inf
11930:0:NaN
119411:2:5
1195-11:-2:5
1196-11:2:-5
119711:-2:-5
61f5c3f5 11980:1:0
11990:-1:0
12001:1:1
1201-1:-1:1
12021:-1:-1
1203-1:1:-1
12041:2:0
12052:1:2
12061:26:0
12071000000000:9:111111111
12082000000000:9:222222222
12093000000000:9:333333333
12104000000000:9:444444444
12115000000000:9:555555555
12126000000000:9:666666666
12137000000000:9:777777777
12148000000000:9:888888888
12159000000000:9:1000000000
121635500000:113:314159
121771000000:226:314159
1218106500000:339:314159
12191000000000:3:333333333
1220+10:+5:2
1221+100:+4:25
1222+1000:+8:125
1223+10000:+16:625
1224999999999999:9:111111111111
1225999999999999:99:10101010101
1226999999999999:999:1001001001
1227999999999999:9999:100010001
1228999999999999999:99999:10000100001
1229+1111088889:99999:11111
6854fd01 1230-5:-3:1
1231-5:3:-1
12324:3:1
12334:-3:-1
12341:3:0
12351:-3:0
1236-2:-3:0
1237-2:3:0
12388:3:2
1239-8:3:-2
124014:-3:-4
1241-14:3:-4
1242-14:-3:4
124314:3:4
1244# bug in Calc with '99999' vs $BASE-1
124510000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1246&bmod
1247# inf handling, see table in doc
12480:inf:0
12490:-inf:0
12505:inf:5
12515:-inf:5
1252-5:inf:-5
1253-5:-inf:-5
1254inf:5:0
1255-inf:5:0
1256inf:-5:0
1257-inf:-5:0
12585:5:0
1259-5:-5:0
b3abae2a 1260inf:inf:NaN
1261-inf:-inf:NaN
1262-inf:inf:NaN
1263inf:-inf:NaN
6854fd01 12648:0:8
1265inf:0:inf
1266# exceptions to reminder rule
1267-inf:0:-inf
1268-8:0:-8
12690:0:NaN
1270abc:abc:NaN
61f5c3f5 1271abc:1:abc:NaN
12721:abc:NaN
12730:0:NaN
12740:1:0
12751:0:1
12760:-1:0
1277-1:0:-1
12781:1:0
1279-1:-1:0
12801:-1:0
1281-1:1:0
12821:2:1
12832:1:0
12841000000000:9:1
12852000000000:9:2
12863000000000:9:3
12874000000000:9:4
12885000000000:9:5
12896000000000:9:6
12907000000000:9:7
12918000000000:9:8
12929000000000:9:0
129335500000:113:33
129471000000:226:66
1295106500000:339:99
12961000000000:3:1
129710:5:0
1298100:4:0
12991000:8:0
130010000:16:0
1301999999999999:9:0
1302999999999999:99:0
1303999999999999:999:0
1304999999999999:9999:0
1305999999999999999:99999:0
1306-9:+5:1
6854fd01 1307+9:-5:-1
1308-9:-5:-4
1309-5:3:1
1310-2:3:1
13114:3:1
13121:3:1
1313-5:-3:-2
1314-2:-3:-2
13154:-3:-2
13161:-3:-2
13174095:4095:0
027dc388 1318100041000510123:3:0
1319152403346:12345:4321
b3abae2a 13209:5:4
6854fd01 1321&bgcd
1322abc:abc:NaN
1323abc:+0:NaN
1324+0:abc:NaN
61f5c3f5 1325+0:+0:0
1326+0:+1:1
1327+1:+0:1
1328+1:+1:1
1329+2:+3:1
1330+3:+2:1
1331-3:+2:1
1332100:625:25
13334096:81:1
13341034:804:2
133527:90:56:1
133627:90:54:9
6854fd01 1337&blcm
1338abc:abc:NaN
1339abc:+0:NaN
1340+0:abc:NaN
1341+0:+0:NaN
61f5c3f5 1342+1:+0:0
1343+0:+1:0
1344+27:+90:270
1345+1034:+804:415668
6854fd01 1346&band
1347abc:abc:NaN
1348abc:0:NaN
13490:abc:NaN
13501:2:0
13513:2:2
61f5c3f5 1352+8:+2:0
1353+281474976710656:0:0
1354+281474976710656:1:0
1355+281474976710656:+281474976710656:281474976710656
6854fd01 1356-2:-3:-4
1357-1:-1:-1
1358-6:-6:-6
1359-7:-4:-8
1360-7:4:0
1361-4:7:4
394e6ffb 1362# equal arguments are treated special, so also do some test with unequal ones
13630xFFFF:0xFFFF:0x0xFFFF
13640xFFFFFF:0xFFFFFF:0x0xFFFFFF
13650xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
13660xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
13670xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
13680xF0F0:0xF0F0:0x0xF0F0
13690x0F0F:0x0F0F:0x0x0F0F
13700xF0F0F0:0xF0F0F0:0x0xF0F0F0
13710x0F0F0F:0x0F0F0F:0x0x0F0F0F
13720xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
13730x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
13740xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
13750x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
13760xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
13770x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
13780x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1379&bior
1380abc:abc:NaN
1381abc:0:NaN
13820:abc:NaN
13831:2:3
61f5c3f5 1384+8:+2:10
1385+281474976710656:0:281474976710656
1386+281474976710656:1:281474976710657
1387+281474976710656:281474976710656:281474976710656
6854fd01 1388-2:-3:-1
1389-1:-1:-1
1390-6:-6:-6
1391-7:4:-3
1392-4:7:-1
394e6ffb 1393# equal arguments are treated special, so also do some test with unequal ones
13940xFFFF:0xFFFF:0x0xFFFF
13950xFFFFFF:0xFFFFFF:0x0xFFFFFF
13960xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
13970xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
13980xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
13990:0xFFFF:0x0xFFFF
14000:0xFFFFFF:0x0xFFFFFF
14010:0xFFFFFFFF:0x0xFFFFFFFF
14020:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14030:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14040xFFFF:0:0x0xFFFF
14050xFFFFFF:0:0x0xFFFFFF
14060xFFFFFFFF:0:0x0xFFFFFFFF
14070xFFFFFFFFFF:0:0x0xFFFFFFFFFF
14080xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
14090xF0F0:0xF0F0:0x0xF0F0
14100x0F0F:0x0F0F:0x0x0F0F
14110xF0F0:0x0F0F:0x0xFFFF
14120xF0F0F0:0xF0F0F0:0x0xF0F0F0
14130x0F0F0F:0x0F0F0F:0x0x0F0F0F
14140x0F0F0F:0xF0F0F0:0x0xFFFFFF
14150xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
14160x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
14170x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
14180xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
14190x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
14200x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
14210xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
14220x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
14230x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
14240x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1425&bxor
1426abc:abc:NaN
1427abc:0:NaN
14280:abc:NaN
14291:2:3
61f5c3f5 1430+8:+2:10
1431+281474976710656:0:281474976710656
1432+281474976710656:1:281474976710657
1433+281474976710656:281474976710656:0
6854fd01 1434-2:-3:3
1435-1:-1:0
1436-6:-6:0
1437-7:4:-3
1438-4:7:-5
14394:-7:-3
1440-4:-7:5
394e6ffb 1441# equal arguments are treated special, so also do some test with unequal ones
14420xFFFF:0xFFFF:0
14430xFFFFFF:0xFFFFFF:0
14440xFFFFFFFF:0xFFFFFFFF:0
14450xFFFFFFFFFF:0xFFFFFFFFFF:0
14460xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
14470:0xFFFF:0x0xFFFF
14480:0xFFFFFF:0x0xFFFFFF
14490:0xFFFFFFFF:0x0xFFFFFFFF
14500:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14510:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14520xFFFF:0:0x0xFFFF
14530xFFFFFF:0:0x0xFFFFFF
14540xFFFFFFFF:0:0x0xFFFFFFFF
14550xFFFFFFFFFF:0:0x0xFFFFFFFFFF
14560xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
14570xF0F0:0xF0F0:0
14580x0F0F:0x0F0F:0
14590xF0F0:0x0F0F:0x0xFFFF
14600xF0F0F0:0xF0F0F0:0
14610x0F0F0F:0x0F0F0F:0
14620x0F0F0F:0xF0F0F0:0x0xFFFFFF
14630xF0F0F0F0:0xF0F0F0F0:0
14640x0F0F0F0F:0x0F0F0F0F:0
14650x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
14660xF0F0F0F0F0:0xF0F0F0F0F0:0
14670x0F0F0F0F0F:0x0F0F0F0F0F:0
14680x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
14690xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
14700x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
14710x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1472&bnot
1473abc:NaN
1474+0:-1
1475+8:-9
1476+281474976710656:-281474976710657
1477-1:0
1478-2:1
1479-12:11
1480&digit
14810:0:0
148212:0:2
148312:1:1
1484123:0:3
1485123:1:2
1486123:2:1
1487123:-1:1
1488123:-2:2
1489123:-3:3
1490123456:0:6
1491123456:1:5
1492123456:2:4
1493123456:3:3
1494123456:4:2
1495123456:5:1
1496123456:-1:1
1497123456:-2:2
1498123456:-3:3
1499100000:-3:0
1500100000:0:0
1501100000:1:0
1502&mantissa
1503abc:NaN
15041e4:1
15052e0:2
1506123:123
1507-1:-1
1508-2:-2
1509+inf:inf
1510-inf:-inf
1511&exponent
1512abc:NaN
15131e4:4
15142e0:0
1515123:0
1516-1:0
1517-2:0
15180:1
1519+inf:inf
1520-inf:inf
1521&parts
1522abc:NaN,NaN
15231e4:1,4
15242e0:2,0
1525123:123,0
1526-1:-1,0
1527-2:-2,0
15280:0,1
1529+inf:inf,inf
1530-inf:-inf,inf
b3abae2a 1531&bfac
1532-1:NaN
1533NaNfac:NaN
1534+inf:NaN
1535-inf:NaN
15360:1
15371:1
15382:2
15393:6
15404:24
15415:120
15426:720
154310:3628800
154411:39916800
154512:479001600
6854fd01 1546&bpow
1547abc:12:NaN
154812:abc:NaN
15490:0:1
15500:1:0
15510:2:0
15520:-1:NaN
15530:-2:NaN
15541:0:1
15551:1:1
15561:2:1
15571:3:1
15581:-1:1
15591:-2:1
15601:-3:1
15612:0:1
15622:1:2
15632:2:4
15642:3:8
15653:3:27
15662:-1:NaN
1567-2:-1:NaN
15682:-2:NaN
1569-2:-2:NaN
1570+inf:1234500012:inf
1571-inf:1234500012:-inf
1572+inf:-12345000123:inf
1573-inf:-12345000123:-inf
1574# 1 ** -x => 1 / (1 ** x)
1575-1:0:1
1576-2:0:1
1577-1:1:-1
1578-1:2:1
1579-1:3:-1
1580-1:4:1
1581-1:5:-1
1582-1:-1:-1
1583-1:-2:1
1584-1:-3:-1
1585-1:-4:1
158610:2:100
158710:3:1000
158810:4:10000
158910:5:100000
159010:6:1000000
159110:7:10000000
159210:8:100000000
159310:9:1000000000
159410:20:100000000000000000000
1595123456:2:15241383936
1596&length
1597100:3
159810:2
15991:1
16000:1
160112345:5
160210000000000000000:17
1603-123:3
1604215960156869840440586892398248:30
1605&bsqrt
394e6ffb 1606145:12
6854fd01 1607144:12
394e6ffb 1608143:11
6854fd01 160916:4
394e6ffb 1610170:13
1611169:13
1612168:12
6854fd01 16134:2
394e6ffb 16143:1
6854fd01 16152:1
394e6ffb 16169:3
6854fd01 161712:3
1618256:16
1619100000000:10000
16204000000000000:2000000
394e6ffb 1621152399026:12345
1622152399025:12345
1623152399024:12344
6854fd01 16241:1
16250:0
1626-2:NaN
394e6ffb 1627-123:NaN
6854fd01 1628Nan:NaN
394e6ffb 1629+inf:NaN
6854fd01 1630&bround
1631$round_mode('trunc')
16320:12:0
1633NaNbround:12:NaN
1634+inf:12:inf
1635-inf:12:-inf
16361234:0:1234
16371234:2:1200
1638123456:4:123400
1639123456:5:123450
1640123456:6:123456
61f5c3f5 1641+10123456789:5:10123000000
6854fd01 1642-10123456789:5:-10123000000
61f5c3f5 1643+10123456789:9:10123456700
6854fd01 1644-10123456789:9:-10123456700
61f5c3f5 1645+101234500:6:101234000
6854fd01 1646-101234500:6:-101234000
61f5c3f5 1647#+101234500:-4:101234000
6854fd01 1648#-101234500:-4:-101234000
1649$round_mode('zero')
61f5c3f5 1650+20123456789:5:20123000000
6854fd01 1651-20123456789:5:-20123000000
61f5c3f5 1652+20123456789:9:20123456800
6854fd01 1653-20123456789:9:-20123456800
61f5c3f5 1654+201234500:6:201234000
6854fd01 1655-201234500:6:-201234000
61f5c3f5 1656#+201234500:-4:201234000
6854fd01 1657#-201234500:-4:-201234000
1658+12345000:4:12340000
1659-12345000:4:-12340000
1660$round_mode('+inf')
61f5c3f5 1661+30123456789:5:30123000000
6854fd01 1662-30123456789:5:-30123000000
61f5c3f5 1663+30123456789:9:30123456800
6854fd01 1664-30123456789:9:-30123456800
61f5c3f5 1665+301234500:6:301235000
6854fd01 1666-301234500:6:-301234000
61f5c3f5 1667#+301234500:-4:301235000
6854fd01 1668#-301234500:-4:-301234000
1669+12345000:4:12350000
1670-12345000:4:-12340000
1671$round_mode('-inf')
61f5c3f5 1672+40123456789:5:40123000000
6854fd01 1673-40123456789:5:-40123000000
61f5c3f5 1674+40123456789:9:40123456800
6854fd01 1675-40123456789:9:-40123456800
61f5c3f5 1676+401234500:6:401234000
1677+401234500:6:401234000
6854fd01 1678#-401234500:-4:-401235000
1679#-401234500:-4:-401235000
1680+12345000:4:12340000
1681-12345000:4:-12350000
1682$round_mode('odd')
61f5c3f5 1683+50123456789:5:50123000000
6854fd01 1684-50123456789:5:-50123000000
61f5c3f5 1685+50123456789:9:50123456800
6854fd01 1686-50123456789:9:-50123456800
61f5c3f5 1687+501234500:6:501235000
6854fd01 1688-501234500:6:-501235000
61f5c3f5 1689#+501234500:-4:501235000
6854fd01 1690#-501234500:-4:-501235000
1691+12345000:4:12350000
1692-12345000:4:-12350000
1693$round_mode('even')
61f5c3f5 1694+60123456789:5:60123000000
6854fd01 1695-60123456789:5:-60123000000
61f5c3f5 1696+60123456789:9:60123456800
6854fd01 1697-60123456789:9:-60123456800
61f5c3f5 1698+601234500:6:601234000
6854fd01 1699-601234500:6:-601234000
61f5c3f5 1700#+601234500:-4:601234000
6854fd01 1701#-601234500:-4:-601234000
1702#-601234500:-9:0
1703#-501234500:-9:0
1704#-601234500:-8:0
1705#-501234500:-8:0
1706+1234567:7:1234567
1707+1234567:6:1234570
1708+12345000:4:12340000
1709-12345000:4:-12340000
1710&is_zero
17110:1
1712NaNzero:0
1713+inf:0
1714-inf:0
1715123:0
1716-1:0
17171:0
1718&is_one
17190:0
1720NaNone:0
1721+inf:0
1722-inf:0
17231:1
17242:0
1725-1:0
1726-2:0
1727# floor and ceil tests are pretty pointless in integer space...but play safe
1728&bfloor
17290:0
1730NaNfloor:NaN
1731+inf:inf
1732-inf:-inf
1733-1:-1
1734-2:-2
17352:2
17363:3
1737abc:NaN
1738&bceil
1739NaNceil:NaN
1740+inf:inf
1741-inf:-inf
17420:0
1743-1:-1
1744-2:-2
17452:2
17463:3
1747abc:NaN
1748&as_hex
1749128:0x80
1750-128:-0x80
17510:0x0
1752-0:0x0
17531:0x1
17540x123456789123456789:0x123456789123456789
1755+inf:inf
1756-inf:-inf
1757NaNas_hex:NaN
1758&as_bin
1759128:0b10000000
1760-128:-0b10000000
17610:0b0
1762-0:0b0
17631:0b1
17640b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1765+inf:inf
1766-inf:-inf
1767NaNas_bin:NaN