Upgrade to Math::BigInt 1.48.
[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
10use Math::BigInt;
11#use Math::BigInt lib => 'BitVect'; # for testing
12use vars qw/@ISA/;
13@ISA = (qw/Math::BigInt/);
14
15use overload
16# customized overload for sub, since original does not use swap there
17'-' => sub { my @a = ref($_[0])->_swap(@_);
18 $a[0]->bsub($a[1])};
19
20sub _swap
21 {
22 # a fake _swap, which reverses the params
23 my $self = shift; # for override in subclass
24 if ($_[2])
25 {
26 my $c = ref ($_[0] ) || 'Math::Foo';
27 return ( $_[0]->copy(), $_[1] );
28 }
29 else
30 {
31 return ( Math::Foo->new($_[1]), $_[0] );
32 }
33 }
34
35##############################################################################
36package main;
37
394e6ffb 38my $CALC = $class->_core_lib(); ok ($CALC,$CL);
6854fd01 39
40my ($f,$z,$a,$exp,@a,$m,$e,$round_mode);
41
42while (<DATA>)
43 {
44 chop;
45 next if /^#/; # skip comments
46 if (s/^&//)
47 {
48 $f = $_;
49 }
50 elsif (/^\$/)
51 {
52 $round_mode = $_;
53 $round_mode =~ s/^\$/$class\->/;
54 # print "$round_mode\n";
55 }
56 else
57 {
58 @args = split(/:/,$_,99);
59 $ans = pop(@args);
60 $try = "\$x = $class->new(\"$args[0]\");";
61 if ($f eq "bnorm"){
62 $try = "\$x = $class->bnorm(\"$args[0]\");";
027dc388 63 # some is_xxx tests
64 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan)$/) {
65 $try .= "\$x->$f();";
6854fd01 66 } elsif ($f eq "as_hex") {
67 $try .= '$x->as_hex();';
68 } elsif ($f eq "as_bin") {
69 $try .= '$x->as_bin();';
70 } elsif ($f eq "is_inf") {
71 $try .= "\$x->is_inf('$args[1]');";
72 } elsif ($f eq "binf") {
73 $try .= "\$x->binf('$args[1]');";
74 } elsif ($f eq "bone") {
75 $try .= "\$x->bone('$args[1]');";
027dc388 76 # some unary ops
77 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt)$/) {
78 $try .= "\$x->$f();";
6854fd01 79 }elsif ($f eq "length") {
80 $try .= '$x->length();';
81 }elsif ($f eq "exponent"){
82 # ->bstr() to see if an object is returned
83 $try .= '$x = $x->exponent()->bstr();';
84 }elsif ($f eq "mantissa"){
85 # ->bstr() to see if an object is returned
86 $try .= '$x = $x->mantissa()->bstr();';
87 }elsif ($f eq "parts"){
88 $try .= '($m,$e) = $x->parts();';
89 # ->bstr() to see if an object is returned
90 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
91 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
92 $try .= '"$m,$e";';
93 } else {
94 $try .= "\$y = $class->new('$args[1]');";
95 if ($f eq "bcmp"){
96 $try .= '$x <=> $y;';
97 }elsif ($f eq "bround") {
98 $try .= "$round_mode; \$x->bround(\$y);";
99 }elsif ($f eq "bacmp"){
100 $try .= '$x->bacmp($y);';
101 }elsif ($f eq "badd"){
102 $try .= '$x + $y;';
103 }elsif ($f eq "bsub"){
104 $try .= '$x - $y;';
105 }elsif ($f eq "bmul"){
106 $try .= '$x * $y;';
107 }elsif ($f eq "bdiv"){
108 $try .= '$x / $y;';
109 }elsif ($f eq "bdiv-list"){
110 $try .= 'join (",",$x->bdiv($y));';
027dc388 111 # overload via x=
112 }elsif ($f =~ /^.=$/){
113 $try .= "\$x $f \$y;";
114 # overload via x
115 }elsif ($f =~ /^.$/){
116 $try .= "\$x $f \$y;";
6854fd01 117 }elsif ($f eq "bmod"){
118 $try .= '$x % $y;';
119 }elsif ($f eq "bgcd")
120 {
121 if (defined $args[2])
122 {
123 $try .= " \$z = $class->new(\"$args[2]\"); ";
124 }
125 $try .= "$class\::bgcd(\$x, \$y";
126 $try .= ", \$z" if (defined $args[2]);
127 $try .= " );";
128 }
129 elsif ($f eq "blcm")
130 {
131 if (defined $args[2])
132 {
133 $try .= " \$z = $class->new(\"$args[2]\"); ";
134 }
135 $try .= "$class\::blcm(\$x, \$y";
136 $try .= ", \$z" if (defined $args[2]);
137 $try .= " );";
138 }elsif ($f eq "blsft"){
139 if (defined $args[2])
140 {
141 $try .= "\$x->blsft(\$y,$args[2]);";
142 }
143 else
144 {
145 $try .= "\$x << \$y;";
146 }
147 }elsif ($f eq "brsft"){
148 if (defined $args[2])
149 {
150 $try .= "\$x->brsft(\$y,$args[2]);";
151 }
152 else
153 {
154 $try .= "\$x >> \$y;";
155 }
156 }elsif ($f eq "band"){
157 $try .= "\$x & \$y;";
158 }elsif ($f eq "bior"){
159 $try .= "\$x | \$y;";
160 }elsif ($f eq "bxor"){
161 $try .= "\$x ^ \$y;";
162 }elsif ($f eq "bpow"){
163 $try .= "\$x ** \$y;";
164 }elsif ($f eq "digit"){
165 $try = "\$x = $class->new(\"$args[0]\"); \$x->digit($args[1]);";
166 } else { warn "Unknown op '$f'"; }
167 }
394e6ffb 168 # print "trying $try\n";
6854fd01 169 $ans1 = eval $try;
394e6ffb 170 # remove leading '+' from target
171 $ans =~ s/^[+]([0-9])/$1/;
172 # convert hex/binary targets to decimal
173 if ($ans =~ /^(0x0x|0b0b)/)
174 {
175 $ans =~ s/^0[xb]//;
176 $ans = Math::BigInt->new($ans)->bstr();
177 }
6854fd01 178 if ($ans eq "")
179 {
180 ok_undef ($ans1);
181 }
182 else
183 {
184 # print "try: $try ans: $ans1 $ans\n";
185 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
186 }
187 # check internal state of number objects
188 is_valid($ans1,$f) if ref $ans1;
189 }
190 } # endwhile data tests
191close DATA;
192
193# test some more
194@a = ();
195for (my $i = 1; $i < 10; $i++)
196 {
197 push @a, $i;
198 }
199ok "@a", "1 2 3 4 5 6 7 8 9";
200
201# test whether self-multiplication works correctly (result is 2**64)
202$try = "\$x = $class->new('4294967296');";
203$try .= '$a = $x->bmul($x);';
204$ans1 = eval $try;
205print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
206# test self-pow
207$try = "\$x = $class->new(10);";
208$try .= '$a = $x->bpow($x);';
209$ans1 = eval $try;
210print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
211
212# test whether op destroys args or not (should better not)
213
214$x = $class->new(3);
215$y = $class->new(4);
216$z = $x & $y;
217ok ($x,3);
218ok ($y,4);
219ok ($z,0);
220$z = $x | $y;
221ok ($x,3);
222ok ($y,4);
223ok ($z,7);
224$x = $class->new(1);
225$y = $class->new(2);
226$z = $x | $y;
227ok ($x,1);
228ok ($y,2);
229ok ($z,3);
230
231$x = $class->new(5);
232$y = $class->new(4);
233$z = $x ^ $y;
234ok ($x,5);
235ok ($y,4);
236ok ($z,1);
237
238$x = $class->new(-5); $y = -$x;
239ok ($x, -5);
240
241$x = $class->new(-5); $y = abs($x);
242ok ($x, -5);
243
244# check whether overloading cmp works
245$try = "\$x = $class->new(0);";
246$try .= "\$y = 10;";
247$try .= "'false' if \$x ne \$y;";
248$ans = eval $try;
249print "# For '$try'\n" if (!ok "$ans" , "false" );
250
251# we cant test for working cmpt with other objects here, we would need a dummy
252# object with stringify overload for this. see Math::String tests as example
253
254###############################################################################
6854fd01 255# check reversed order of arguments
027dc388 256
6854fd01 257$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
258$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
259print "# For '$try'\n" if (!ok "$ans" , "ok" );
260
261$try = "\$x = $class->new(10); \$x = 2 * \$x;";
262$try .= "'ok' if \$x == 20;"; $ans = eval $try;
263print "# For '$try'\n" if (!ok "$ans" , "ok" );
264
265$try = "\$x = $class->new(10); \$x = 2 + \$x;";
266$try .= "'ok' if \$x == 12;"; $ans = eval $try;
267print "# For '$try'\n" if (!ok "$ans" , "ok" );
268
269$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
270$try .= "'ok' if \$x == -8;"; $ans = eval $try;
271print "# For '$try'\n" if (!ok "$ans" , "ok" );
272
273$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
274$try .= "'ok' if \$x == 2;"; $ans = eval $try;
275print "# For '$try'\n" if (!ok "$ans" , "ok" );
276
027dc388 277$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
278$try .= "'ok' if \$x == 2;"; $ans = eval $try;
279print "# For '$try'\n" if (!ok "$ans" , "ok" );
280
281$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
282$try .= "'ok' if \$x == 4;"; $ans = eval $try;
283print "# For '$try'\n" if (!ok "$ans" , "ok" );
284
285$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
286$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
287print "# For '$try'\n" if (!ok "$ans" , "ok" );
288
289$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
290$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
291print "# For '$try'\n" if (!ok "$ans" , "ok" );
292
6854fd01 293###############################################################################
294# check badd(4,5) form
295
296$try = "\$x = $class\->badd(4,5);";
297$try .= "'ok' if \$x == 9;";
298$ans = eval $try;
299print "# For '$try'\n" if (!ok "$ans" , "ok" );
300
301###############################################################################
302# check undefs: NOT DONE YET
303
304###############################################################################
305# bool
306
307$x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
308$x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
309
310###############################################################################
311# objectify()
312
313@args = Math::BigInt::objectify(2,4,5);
314ok (scalar @args,3); # $class, 4, 5
315ok ($args[0],$class);
316ok ($args[1],4);
317ok ($args[2],5);
318
319@args = Math::BigInt::objectify(0,4,5);
320ok (scalar @args,3); # $class, 4, 5
321ok ($args[0],$class);
322ok ($args[1],4);
323ok ($args[2],5);
324
325@args = Math::BigInt::objectify(2,4,5);
326ok (scalar @args,3); # $class, 4, 5
327ok ($args[0],$class);
328ok ($args[1],4);
329ok ($args[2],5);
330
331@args = Math::BigInt::objectify(2,4,5,6,7);
332ok (scalar @args,5); # $class, 4, 5, 6, 7
333ok ($args[0],$class);
334ok ($args[1],4); ok (ref($args[1]),$args[0]);
335ok ($args[2],5); ok (ref($args[2]),$args[0]);
336ok ($args[3],6); ok (ref($args[3]),'');
337ok ($args[4],7); ok (ref($args[4]),'');
338
339@args = Math::BigInt::objectify(2,$class,4,5,6,7);
340ok (scalar @args,5); # $class, 4, 5, 6, 7
341ok ($args[0],$class);
342ok ($args[1],4); ok (ref($args[1]),$args[0]);
343ok ($args[2],5); ok (ref($args[2]),$args[0]);
344ok ($args[3],6); ok (ref($args[3]),'');
345ok ($args[4],7); ok (ref($args[4]),'');
346
347###############################################################################
348# test for floating-point input (other tests in bnorm() below)
349
350$z = 1050000000000000; # may be int on systems with 64bit?
351$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
352$z = 1e+129; # definitely a float (may fail on UTS)
353# don't compare to $z, since some Perl versions stringify $z into something
354# like '1.e+129' or something equally ugly
355$x = $class->new($z); ok ($x->bsstr(),'1e+129');
356
357###############################################################################
358# prime number tests, also test for **= and length()
359# found on: http://www.utm.edu/research/primes/notes/by_year.html
360
361# ((2^148)-1)/17
362$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
363ok ($x,"20988936657440586486151264256610222593863921");
364ok ($x->length(),length "20988936657440586486151264256610222593863921");
365
366# MM7 = 2^127-1
367$x = $class->new(2); $x **= 127; $x--;
368ok ($x,"170141183460469231731687303715884105727");
369
370$x = $class->new('215960156869840440586892398248');
371($x,$y) = $x->length();
372ok ($x,30); ok ($y,0);
373
374$x = $class->new('1_000_000_000_000');
375($x,$y) = $x->length();
376ok ($x,13); ok ($y,0);
377
378# I am afraid the following is not yet possible due to slowness
379# Also, testing for 2 meg output is a bit hard ;)
380#$x = $class->new(2); $x **= 6972593; $x--;
381
382# 593573509*2^332162+1 has exactly 1,000,000 digits
383# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
384#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
385#ok ($x->length(),1_000_000);
386
387###############################################################################
388# inheritance and overriding of _swap
389
390$x = Math::Foo->new(5);
391$x = $x - 8; # 8 - 5 instead of 5-8
392ok ($x,3);
393ok (ref($x),'Math::Foo');
394
395$x = Math::Foo->new(5);
396$x = 8 - $x; # 5 - 8 instead of 8 - 5
397ok ($x,-3);
398ok (ref($x),'Math::Foo');
399
400###############################################################################
401# Test whether +inf eq inf
402# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
403# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
404# like 1e100000 crash on some platforms. So simple test for the string 'inf'
405$x = $class->new('+inf'); ok ($x,'inf');
406
407###############################################################################
408###############################################################################
394e6ffb 409# the followin tests only make sense with Math::BigInt::Calc or BareCalc
6854fd01 410
394e6ffb 411exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
6854fd01 412
413###############################################################################
414# check proper length of internal arrays
415
394e6ffb 416my $bl = $CL->_base_len();
6854fd01 417my $BASE = '9' x $bl;
418my $MAX = $BASE;
419$BASE++;
420
421$x = $class->new($MAX); is_valid($x); # f.i. 9999
422$x += 1; ok ($x,$BASE); is_valid($x); # 10000
423$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
424
425###############################################################################
426# check numify
427
428$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
429$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
430$x = $class->new($BASE); ok ($x->numify(),$BASE);
431$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
432$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
433ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
434
435###############################################################################
436# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
437
394e6ffb 438$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
439if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
440
441$x = $class->new($BASE+3); $x++;
442if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 443
394e6ffb 444# test for +0 instead of int():
445$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 446
447###############################################################################
448# bug in sub where number with at least 6 trailing zeros after any op failed
449
394e6ffb 450$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 451ok ($z, 100000);
452ok ($x, 23456);
453
454###############################################################################
455# bug in shortcut in mul()
456
457# construct a number with a zero-hole of BASE_LEN
458$x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
459$y = '1' x (2*$bl);
394e6ffb 460$x = $class->new($x)->bmul($y);
6854fd01 461# result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
462$y = ''; my $d = '';
463for (my $i = 1; $i <= $bl; $i++)
464 {
465 $y .= $i; $d = $i.$d;
466 }
6854fd01 467$y .= $bl x (3*$bl-1) . $d . '0' x $bl;
468ok ($x,$y);
469
470###############################################################################
394e6ffb 471# see if mul shortcut for small numbers works
472
473$x = '9' x $bl;
474$x = $class->new($x);
475# 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
476ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
477
478###############################################################################
6854fd01 479# bug with rest "-0" in div, causing further div()s to fail
480
394e6ffb 481$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 482
483ok ($y,'0','not -0'); # not '-0'
484is_valid($y);
485
394e6ffb 486###############################################################################
487# test whether bone/bzero take additional A & P, or reset it etc
488
489$x = $class->new(2); $x->bzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
490$x = $class->new(2); $x->binf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
491$x = $class->new(2); $x->bone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
492$x = $class->new(2); $x->bnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
493
494$x = $class->new(2); $x->{_a} = 1; $x->{_p} = 2; $x->bnan();
495ok_undef ($x->{_a}); ok_undef ($x->{_p});
496$x = $class->new(2); $x->{_a} = 1; $x->{_p} = 2; $x->binf();
497ok_undef ($x->{_a}); ok_undef ($x->{_p});
498
6854fd01 499### all tests done ############################################################
500
5011;
502
503###############################################################################
504# Perl 5.005 does not like ok ($x,undef)
505
506sub ok_undef
507 {
508 my $x = shift;
509
510 ok (1,1) and return if !defined $x;
511 ok ($x,'undef');
512 }
513
514###############################################################################
515# sub to check validity of a BigInt internally, to ensure that no op leaves a
516# number object in an invalid state (f.i. "-0")
517
518sub is_valid
519 {
520 my ($x,$f) = @_;
521
522 my $e = 0; # error?
523 # ok as reference?
524 $e = 'Not a reference to Math::BigInt' if !ref($x);
525
526 # has ok sign?
527 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
528 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
529
530 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
531 $e = $CALC->_check($x->{value}) if $e eq '0';
532
533 # test done, see if error did crop up
534 ok (1,1), return if ($e eq '0');
535
027dc388 536 ok (1,$e." after op '$f'");
6854fd01 537 }
538
539__DATA__
027dc388 540&.=
5411234:-345:1234-345
542&+=
5431:2:3
544-1:-2:-3
545&-=
5461:2:-1
547-1:-2:1
548&*=
5492:3:6
550-1:5:-5
551&%=
552100:3:1
5538:9:8
554&/=
555100:3:33
556-8:2:-4
557&|=
5582:1:3
559&&=
5605:7:5
561&^=
5625:7:2
6854fd01 563&is_negative
5640:0
565-1:1
5661:0
567+inf:0
568-inf:1
569NaNneg:0
570&is_positive
5710:1
572-1:0
5731:1
574+inf:1
575-inf:0
576NaNneg:0
577&is_odd
578abc:0
5790:0
5801:1
5813:1
582-1:1
583-3:1
58410000001:1
58510000002:0
5862:0
587&is_even
588abc:0
5890:1
5901:0
5913:0
592-1:0
593-3:0
59410000001:0
59510000002:1
5962:1
597&bacmp
598+0:-0:0
599+0:+1:-1
600-1:+1:0
601+1:-1:0
602-1:+2:-1
603+2:-1:1
604-123456789:+987654321:-1
605+123456789:-987654321:-1
606+987654321:+123456789:1
607-987654321:+123456789:1
608-123:+4567889:-1
609# NaNs
610acmpNaN:123:
611123:acmpNaN:
612acmpNaN:acmpNaN:
613# infinity
614+inf:+inf:0
615-inf:-inf:0
616+inf:-inf:0
617-inf:+inf:0
618+inf:123:1
619-inf:123:1
620+inf:-123:1
621-inf:-123:1
622# return undef
623+inf:NaN:
624NaN:inf:
625-inf:NaN:
626NaN:-inf:
627&bnorm
628123:123
629# binary input
6300babc:NaN
6310b123:NaN
6320b0:0
633-0b0:0
634-0b1:-1
6350b0001:1
6360b001:1
6370b011:3
6380b101:5
6390b1000000000000000000000000000000:1073741824
6400b_101:NaN
6410b1_0_1:5
394e6ffb 6420b0_0_0_1:1
6854fd01 643# hex input
644-0x0:0
6450xabcdefgh:NaN
6460x1234:4660
6470xabcdef:11259375
648-0xABCDEF:-11259375
649-0x1234:-4660
6500x12345678:305419896
6510x1_2_3_4_56_78:305419896
394e6ffb 6520xa_b_c_d_e_f:11259375
6854fd01 6530x_123:NaN
654# inf input
655inf:inf
656+inf:inf
657-inf:-inf
6580inf:NaN
027dc388 659# abnormal input
6854fd01 660:NaN
661abc:NaN
662 1 a:NaN
6631bcd2:NaN
66411111b:NaN
665+1z:NaN
666-1z:NaN
027dc388 667# only one underscore between two digits
668_123:NaN
669_123_:NaN
670123_:NaN
6711__23:NaN
6721E1__2:NaN
6731_E12:NaN
6741E_12:NaN
6751_E_12:NaN
676+_1E12:NaN
677+0_1E2:100
678+0_0_1E2:100
679-0_0_1E2:-100
680-0_0_1E+0_0_2:-100
681E1:NaN
682E23:NaN
6831.23E1:NaN
6841.23E-1:NaN
685# bug with two E's in number beeing valid
6861e2e3:NaN
6871e2r:NaN
6881e2.0:NaN
689# normal input
6854fd01 6900:0
691+0:0
692+00:0
693+000:0
694000000000000000000:0
695-0:0
696-0000:0
697+1:1
698+01:1
699+001:1
700+00000100000:100000
701123456789:123456789
702-1:-1
703-01:-1
704-001:-1
705-123456789:-123456789
706-00000100000:-100000
7071_2_3:123
6854fd01 70810000000000E-1_0:1
7091E2:100
7101E1:10
7111E0:1
6854fd01 7121.23E2:123
6854fd01 713100E-1:10
714# floating point input
027dc388 715# .2e2:20
7161.E3:1000
6854fd01 7171.01E2:101
7181010E-1:101
719-1010E0:-1010
720-1010E1:-10100
027dc388 7211234.00:1234
722# non-integer numbers
6854fd01 723-1010E-2:NaN
724-1.01E+1:NaN
725-1.01E-1:NaN
6854fd01 726&bnan
7271:NaN
7282:NaN
729abc:NaN
730&bone
7312:+:+1
7322:-:-1
733boneNaN:-:-1
734boneNaN:+:+1
7352:abc:+1
7363::+1
737&binf
7381:+:inf
7392:-:-inf
7403:abc:inf
027dc388 741&is_nan
742123:0
743abc:1
744NaN:1
745-123:0
6854fd01 746&is_inf
747+inf::1
748-inf::1
749abc::0
7501::0
751NaN::0
752-1::0
753+inf:-:0
754+inf:+:1
755-inf:-:1
756-inf:+:0
757# it must be exactly /^[+-]inf$/
758+infinity::0
759-infinity::0
760&blsft
761abc:abc:NaN
762+2:+2:+8
763+1:+32:+4294967296
764+1:+48:+281474976710656
765+8:-2:NaN
766# excercise base 10
767+12345:4:10:123450000
768-1234:0:10:-1234
769+1234:0:10:+1234
770+2:2:10:200
771+12:2:10:1200
772+1234:-3:10:NaN
7731234567890123:12:10:1234567890123000000000000
774&brsft
775abc:abc:NaN
776+8:+2:+2
777+4294967296:+32:+1
778+281474976710656:+48:+1
779+2:-2:NaN
780# excercise base 10
781-1234:0:10:-1234
782+1234:0:10:+1234
783+200:2:10:2
784+1234:3:10:1
785+1234:2:10:12
786+1234:-3:10:NaN
787310000:4:10:31
78812300000:5:10:123
7891230000000000:10:10:123
79009876123456789067890:12:10:9876123
7911234561234567890123:13:10:123456
792&bsstr
7931e+34:1e+34
794123.456E3:123456e+0
795100:1e+2
796abc:NaN
797&bneg
798bnegNaN:NaN
799+inf:-inf
800-inf:inf
801abd:NaN
802+0:+0
803+1:-1
804-1:+1
805+123456789:-123456789
806-123456789:+123456789
807&babs
808babsNaN:NaN
809+inf:inf
810-inf:inf
811+0:+0
812+1:+1
813-1:+1
814+123456789:+123456789
815-123456789:+123456789
816&bcmp
817bcmpNaN:bcmpNaN:
818bcmpNaN:+0:
819+0:bcmpNaN:
820+0:+0:0
821-1:+0:-1
822+0:-1:1
823+1:+0:1
824+0:+1:-1
825-1:+1:-1
826+1:-1:1
827-1:-1:0
828+1:+1:0
829+123:+123:0
830+123:+12:1
831+12:+123:-1
832-123:-123:0
833-123:-12:-1
834-12:-123:1
835+123:+124:-1
836+124:+123:1
837-123:-124:1
838-124:-123:-1
839+100:+5:1
840-123456789:+987654321:-1
841+123456789:-987654321:1
842-987654321:+123456789:-1
843-inf:5432112345:-1
844+inf:5432112345:1
845-inf:-5432112345:-1
846+inf:-5432112345:1
847+inf:+inf:0
848-inf:-inf:0
849+inf:-inf:1
850-inf:+inf:-1
8515:inf:-1
8525:inf:-1
853-5:-inf:1
854-5:-inf:1
855# return undef
856+inf:NaN:
857NaN:inf:
858-inf:NaN:
859NaN:-inf:
860&binc
861abc:NaN
862+inf:inf
863-inf:-inf
864+0:+1
865+1:+2
866-1:+0
867&bdec
868abc:NaN
869+inf:inf
870-inf:-inf
871+0:-1
872+1:+0
873-1:-2
874&badd
875abc:abc:NaN
876abc:+0:NaN
877+0:abc:NaN
878+inf:-inf:0
879-inf:+inf:0
880+inf:+inf:inf
881-inf:-inf:-inf
882baddNaN:+inf:NaN
883baddNaN:+inf:NaN
884+inf:baddNaN:NaN
885-inf:baddNaN:NaN
886+0:+0:+0
887+1:+0:+1
888+0:+1:+1
889+1:+1:+2
890-1:+0:-1
891+0:-1:-1
892-1:-1:-2
893-1:+1:+0
894+1:-1:+0
895+9:+1:+10
896+99:+1:+100
897+999:+1:+1000
898+9999:+1:+10000
899+99999:+1:+100000
900+999999:+1:+1000000
901+9999999:+1:+10000000
902+99999999:+1:+100000000
903+999999999:+1:+1000000000
904+9999999999:+1:+10000000000
905+99999999999:+1:+100000000000
906+10:-1:+9
907+100:-1:+99
908+1000:-1:+999
909+10000:-1:+9999
910+100000:-1:+99999
911+1000000:-1:+999999
912+10000000:-1:+9999999
913+100000000:-1:+99999999
914+1000000000:-1:+999999999
915+10000000000:-1:+9999999999
916+123456789:+987654321:+1111111110
917-123456789:+987654321:+864197532
918-123456789:-987654321:-1111111110
919+123456789:-987654321:-864197532
920&bsub
921abc:abc:NaN
922abc:+0:NaN
923+0:abc:NaN
924+inf:-inf:inf
925-inf:+inf:-inf
926+inf:+inf:0
927-inf:-inf:0
928+0:+0:+0
929+1:+0:+1
930+0:+1:-1
931+1:+1:+0
932-1:+0:-1
933+0:-1:+1
934-1:-1:+0
935-1:+1:-2
936+1:-1:+2
937+9:+1:+8
938+99:+1:+98
939+999:+1:+998
940+9999:+1:+9998
941+99999:+1:+99998
942+999999:+1:+999998
943+9999999:+1:+9999998
944+99999999:+1:+99999998
945+999999999:+1:+999999998
946+9999999999:+1:+9999999998
947+99999999999:+1:+99999999998
948+10:-1:+11
949+100:-1:+101
950+1000:-1:+1001
951+10000:-1:+10001
952+100000:-1:+100001
953+1000000:-1:+1000001
954+10000000:-1:+10000001
955+100000000:-1:+100000001
956+1000000000:-1:+1000000001
957+10000000000:-1:+10000000001
958+123456789:+987654321:-864197532
959-123456789:+987654321:-1111111110
960-123456789:-987654321:+864197532
961+123456789:-987654321:+1111111110
962&bmul
963abc:abc:NaN
964abc:+0:NaN
965+0:abc:NaN
966NaNmul:+inf:NaN
967NaNmul:-inf:NaN
968-inf:NaNmul:NaN
969+inf:NaNmul:NaN
970+inf:+inf:inf
971+inf:-inf:-inf
972-inf:+inf:-inf
973-inf:-inf:inf
974+0:+0:+0
975+0:+1:+0
976+1:+0:+0
977+0:-1:+0
978-1:+0:+0
979+123456789123456789:+0:+0
980+0:+123456789123456789:+0
981-1:-1:+1
982-1:+1:-1
983+1:-1:-1
984+1:+1:+1
985+2:+3:+6
986-2:+3:-6
987+2:-3:-6
988-2:-3:+6
989+111:+111:+12321
990+10101:+10101:+102030201
991+1001001:+1001001:+1002003002001
992+100010001:+100010001:+10002000300020001
993+10000100001:+10000100001:+100002000030000200001
994+11111111111:+9:+99999999999
995+22222222222:+9:+199999999998
996+33333333333:+9:+299999999997
997+44444444444:+9:+399999999996
998+55555555555:+9:+499999999995
999+66666666666:+9:+599999999994
1000+77777777777:+9:+699999999993
1001+88888888888:+9:+799999999992
1002+99999999999:+9:+899999999991
1003+25:+25:+625
1004+12345:+12345:+152399025
1005+99999:+11111:+1111088889
10069999:10000:99990000
100799999:100000:9999900000
1008999999:1000000:999999000000
10099999999:10000000:99999990000000
101099999999:100000000:9999999900000000
1011999999999:1000000000:999999999000000000
10129999999999:10000000000:99999999990000000000
101399999999999:100000000000:9999999999900000000000
1014999999999999:1000000000000:999999999999000000000000
10159999999999999:10000000000000:99999999999990000000000000
101699999999999999:100000000000000:9999999999999900000000000000
1017999999999999999:1000000000000000:999999999999999000000000000000
10189999999999999999:10000000000000000:99999999999999990000000000000000
101999999999999999999:100000000000000000:9999999999999999900000000000000000
1020999999999999999999:1000000000000000000:999999999999999999000000000000000000
10219999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1022&bdiv-list
1023100:20:5,0
10244095:4095:1,0
1025-4095:-4095:1,0
10264095:-4095:-1,0
1027-4095:4095:-1,0
1028123:2:61,1
1029# inf handling and general remainder
10305:8:0,5
10310:8:0,0
103211:2:5,1
103311:-2:-5,-1
1034-11:2:-5,1
1035# see table in documentation in MBI
10360:inf:0,0
10370:-inf:0,0
10385:inf:0,5
10395:-inf:0,5
1040-5:inf:0,-5
1041-5:-inf:0,-5
1042inf:5:inf,0
1043-inf:5:-inf,0
1044inf:-5:-inf,0
1045-inf:-5:inf,0
10465:5:1,0
1047-5:-5:1,0
1048inf:inf:1,0
1049-inf:-inf:1,0
1050-inf:inf:-1,0
1051inf:-inf:-1,0
10528:0:inf,8
1053inf:0:inf,inf
1054# exceptions to reminder rule
1055-8:0:-inf,-8
1056-inf:0:-inf,-inf
10570:0:NaN,NaN
1058&bdiv
1059abc:abc:NaN
1060abc:+1:NaN
1061+1:abc:NaN
1062+0:+0:NaN
1063# inf handling (see table in doc)
10640:inf:0
10650:-inf:0
10665:inf:0
10675:-inf:0
1068-5:inf:0
1069-5:-inf:0
1070inf:5:inf
1071-inf:5:-inf
1072inf:-5:-inf
1073-inf:-5:inf
10745:5:1
1075-5:-5:1
1076inf:inf:1
1077-inf:-inf:1
1078-inf:inf:-1
1079inf:-inf:-1
10808:0:inf
1081inf:0:inf
1082-8:0:-inf
1083-inf:0:-inf
10840:0:NaN
108511:2:5
1086-11:-2:5
1087-11:2:-5
108811:-2:-5
1089+0:+1:+0
1090+0:-1:+0
1091+1:+1:+1
1092-1:-1:+1
1093+1:-1:-1
1094-1:+1:-1
1095+1:+2:+0
1096+2:+1:+2
1097+1:+26:+0
1098+1000000000:+9:+111111111
1099+2000000000:+9:+222222222
1100+3000000000:+9:+333333333
1101+4000000000:+9:+444444444
1102+5000000000:+9:+555555555
1103+6000000000:+9:+666666666
1104+7000000000:+9:+777777777
1105+8000000000:+9:+888888888
1106+9000000000:+9:+1000000000
1107+35500000:+113:+314159
1108+71000000:+226:+314159
1109+106500000:+339:+314159
1110+1000000000:+3:+333333333
1111+10:+5:+2
1112+100:+4:+25
1113+1000:+8:+125
1114+10000:+16:+625
1115+999999999999:+9:+111111111111
1116+999999999999:+99:+10101010101
1117+999999999999:+999:+1001001001
1118+999999999999:+9999:+100010001
1119+999999999999999:+99999:+10000100001
1120+1111088889:+99999:+11111
1121-5:-3:1
1122-5:3:-1
11234:3:1
11244:-3:-1
11251:3:0
11261:-3:0
1127-2:-3:0
1128-2:3:0
11298:3:2
1130-8:3:-2
113114:-3:-4
1132-14:3:-4
1133-14:-3:4
113414:3:4
1135# bug in Calc with '99999' vs $BASE-1
113610000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1137&bmod
1138# inf handling, see table in doc
11390:inf:0
11400:-inf:0
11415:inf:5
11425:-inf:5
1143-5:inf:-5
1144-5:-inf:-5
1145inf:5:0
1146-inf:5:0
1147inf:-5:0
1148-inf:-5:0
11495:5:0
1150-5:-5:0
1151inf:inf:0
1152-inf:-inf:0
1153-inf:inf:0
1154inf:-inf:0
11558:0:8
1156inf:0:inf
1157# exceptions to reminder rule
1158-inf:0:-inf
1159-8:0:-8
11600:0:NaN
1161abc:abc:NaN
1162abc:+1:abc:NaN
1163+1:abc:NaN
1164+0:+0:NaN
1165+0:+1:+0
1166+1:+0:+1
1167+0:-1:+0
1168-1:+0:-1
1169+1:+1:+0
1170-1:-1:+0
1171+1:-1:+0
1172-1:+1:+0
1173+1:+2:+1
1174+2:+1:+0
1175+1000000000:+9:+1
1176+2000000000:+9:+2
1177+3000000000:+9:+3
1178+4000000000:+9:+4
1179+5000000000:+9:+5
1180+6000000000:+9:+6
1181+7000000000:+9:+7
1182+8000000000:+9:+8
1183+9000000000:+9:+0
1184+35500000:+113:+33
1185+71000000:+226:+66
1186+106500000:+339:+99
1187+1000000000:+3:+1
1188+10:+5:+0
1189+100:+4:+0
1190+1000:+8:+0
1191+10000:+16:+0
1192+999999999999:+9:+0
1193+999999999999:+99:+0
1194+999999999999:+999:+0
1195+999999999999:+9999:+0
1196+999999999999999:+99999:+0
1197-9:+5:+1
1198+9:-5:-1
1199-9:-5:-4
1200-5:3:1
1201-2:3:1
12024:3:1
12031:3:1
1204-5:-3:-2
1205-2:-3:-2
12064:-3:-2
12071:-3:-2
12084095:4095:0
027dc388 1209100041000510123:3:0
1210152403346:12345:4321
6854fd01 1211&bgcd
1212abc:abc:NaN
1213abc:+0:NaN
1214+0:abc:NaN
1215+0:+0:+0
1216+0:+1:+1
1217+1:+0:+1
1218+1:+1:+1
1219+2:+3:+1
1220+3:+2:+1
1221-3:+2:+1
1222+100:+625:+25
1223+4096:+81:+1
1224+1034:+804:+2
1225+27:+90:+56:+1
1226+27:+90:+54:+9
1227&blcm
1228abc:abc:NaN
1229abc:+0:NaN
1230+0:abc:NaN
1231+0:+0:NaN
1232+1:+0:+0
1233+0:+1:+0
1234+27:+90:+270
1235+1034:+804:+415668
1236&band
1237abc:abc:NaN
1238abc:0:NaN
12390:abc:NaN
12401:2:0
12413:2:2
1242+8:+2:+0
1243+281474976710656:+0:+0
1244+281474976710656:+1:+0
1245+281474976710656:+281474976710656:+281474976710656
1246-2:-3:-4
1247-1:-1:-1
1248-6:-6:-6
1249-7:-4:-8
1250-7:4:0
1251-4:7:4
394e6ffb 1252# equal arguments are treated special, so also do some test with unequal ones
12530xFFFF:0xFFFF:0x0xFFFF
12540xFFFFFF:0xFFFFFF:0x0xFFFFFF
12550xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
12560xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
12570xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
12580xF0F0:0xF0F0:0x0xF0F0
12590x0F0F:0x0F0F:0x0x0F0F
12600xF0F0F0:0xF0F0F0:0x0xF0F0F0
12610x0F0F0F:0x0F0F0F:0x0x0F0F0F
12620xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
12630x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
12640xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
12650x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
12660xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
12670x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
12680x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1269&bior
1270abc:abc:NaN
1271abc:0:NaN
12720:abc:NaN
12731:2:3
1274+8:+2:+10
1275+281474976710656:+0:+281474976710656
1276+281474976710656:+1:+281474976710657
1277+281474976710656:+281474976710656:+281474976710656
1278-2:-3:-1
1279-1:-1:-1
1280-6:-6:-6
1281-7:4:-3
1282-4:7:-1
394e6ffb 1283# equal arguments are treated special, so also do some test with unequal ones
12840xFFFF:0xFFFF:0x0xFFFF
12850xFFFFFF:0xFFFFFF:0x0xFFFFFF
12860xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
12870xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
12880xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
12890:0xFFFF:0x0xFFFF
12900:0xFFFFFF:0x0xFFFFFF
12910:0xFFFFFFFF:0x0xFFFFFFFF
12920:0xFFFFFFFFFF:0x0xFFFFFFFFFF
12930:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
12940xFFFF:0:0x0xFFFF
12950xFFFFFF:0:0x0xFFFFFF
12960xFFFFFFFF:0:0x0xFFFFFFFF
12970xFFFFFFFFFF:0:0x0xFFFFFFFFFF
12980xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
12990xF0F0:0xF0F0:0x0xF0F0
13000x0F0F:0x0F0F:0x0x0F0F
13010xF0F0:0x0F0F:0x0xFFFF
13020xF0F0F0:0xF0F0F0:0x0xF0F0F0
13030x0F0F0F:0x0F0F0F:0x0x0F0F0F
13040x0F0F0F:0xF0F0F0:0x0xFFFFFF
13050xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
13060x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
13070x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
13080xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
13090x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
13100x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
13110xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
13120x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
13130x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
13140x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1315&bxor
1316abc:abc:NaN
1317abc:0:NaN
13180:abc:NaN
13191:2:3
1320+8:+2:+10
1321+281474976710656:+0:+281474976710656
1322+281474976710656:+1:+281474976710657
1323+281474976710656:+281474976710656:+0
1324-2:-3:3
1325-1:-1:0
1326-6:-6:0
1327-7:4:-3
1328-4:7:-5
13294:-7:-3
1330-4:-7:5
394e6ffb 1331# equal arguments are treated special, so also do some test with unequal ones
13320xFFFF:0xFFFF:0
13330xFFFFFF:0xFFFFFF:0
13340xFFFFFFFF:0xFFFFFFFF:0
13350xFFFFFFFFFF:0xFFFFFFFFFF:0
13360xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
13370:0xFFFF:0x0xFFFF
13380:0xFFFFFF:0x0xFFFFFF
13390:0xFFFFFFFF:0x0xFFFFFFFF
13400:0xFFFFFFFFFF:0x0xFFFFFFFFFF
13410:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
13420xFFFF:0:0x0xFFFF
13430xFFFFFF:0:0x0xFFFFFF
13440xFFFFFFFF:0:0x0xFFFFFFFF
13450xFFFFFFFFFF:0:0x0xFFFFFFFFFF
13460xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
13470xF0F0:0xF0F0:0
13480x0F0F:0x0F0F:0
13490xF0F0:0x0F0F:0x0xFFFF
13500xF0F0F0:0xF0F0F0:0
13510x0F0F0F:0x0F0F0F:0
13520x0F0F0F:0xF0F0F0:0x0xFFFFFF
13530xF0F0F0F0:0xF0F0F0F0:0
13540x0F0F0F0F:0x0F0F0F0F:0
13550x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
13560xF0F0F0F0F0:0xF0F0F0F0F0:0
13570x0F0F0F0F0F:0x0F0F0F0F0F:0
13580x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
13590xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
13600x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
13610x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1362&bnot
1363abc:NaN
1364+0:-1
1365+8:-9
1366+281474976710656:-281474976710657
1367-1:0
1368-2:1
1369-12:11
1370&digit
13710:0:0
137212:0:2
137312:1:1
1374123:0:3
1375123:1:2
1376123:2:1
1377123:-1:1
1378123:-2:2
1379123:-3:3
1380123456:0:6
1381123456:1:5
1382123456:2:4
1383123456:3:3
1384123456:4:2
1385123456:5:1
1386123456:-1:1
1387123456:-2:2
1388123456:-3:3
1389100000:-3:0
1390100000:0:0
1391100000:1:0
1392&mantissa
1393abc:NaN
13941e4:1
13952e0:2
1396123:123
1397-1:-1
1398-2:-2
1399+inf:inf
1400-inf:-inf
1401&exponent
1402abc:NaN
14031e4:4
14042e0:0
1405123:0
1406-1:0
1407-2:0
14080:1
1409+inf:inf
1410-inf:inf
1411&parts
1412abc:NaN,NaN
14131e4:1,4
14142e0:2,0
1415123:123,0
1416-1:-1,0
1417-2:-2,0
14180:0,1
1419+inf:inf,inf
1420-inf:-inf,inf
1421&bpow
1422abc:12:NaN
142312:abc:NaN
14240:0:1
14250:1:0
14260:2:0
14270:-1:NaN
14280:-2:NaN
14291:0:1
14301:1:1
14311:2:1
14321:3:1
14331:-1:1
14341:-2:1
14351:-3:1
14362:0:1
14372:1:2
14382:2:4
14392:3:8
14403:3:27
14412:-1:NaN
1442-2:-1:NaN
14432:-2:NaN
1444-2:-2:NaN
1445+inf:1234500012:inf
1446-inf:1234500012:-inf
1447+inf:-12345000123:inf
1448-inf:-12345000123:-inf
1449# 1 ** -x => 1 / (1 ** x)
1450-1:0:1
1451-2:0:1
1452-1:1:-1
1453-1:2:1
1454-1:3:-1
1455-1:4:1
1456-1:5:-1
1457-1:-1:-1
1458-1:-2:1
1459-1:-3:-1
1460-1:-4:1
146110:2:100
146210:3:1000
146310:4:10000
146410:5:100000
146510:6:1000000
146610:7:10000000
146710:8:100000000
146810:9:1000000000
146910:20:100000000000000000000
1470123456:2:15241383936
1471&length
1472100:3
147310:2
14741:1
14750:1
147612345:5
147710000000000000000:17
1478-123:3
1479215960156869840440586892398248:30
1480&bsqrt
394e6ffb 1481145:12
6854fd01 1482144:12
394e6ffb 1483143:11
6854fd01 148416:4
394e6ffb 1485170:13
1486169:13
1487168:12
6854fd01 14884:2
394e6ffb 14893:1
6854fd01 14902:1
394e6ffb 14919:3
6854fd01 149212:3
1493256:16
1494100000000:10000
14954000000000000:2000000
394e6ffb 1496152399026:12345
1497152399025:12345
1498152399024:12344
6854fd01 14991:1
15000:0
1501-2:NaN
394e6ffb 1502-123:NaN
6854fd01 1503Nan:NaN
394e6ffb 1504+inf:NaN
6854fd01 1505&bround
1506$round_mode('trunc')
15070:12:0
1508NaNbround:12:NaN
1509+inf:12:inf
1510-inf:12:-inf
15111234:0:1234
15121234:2:1200
1513123456:4:123400
1514123456:5:123450
1515123456:6:123456
1516+10123456789:5:+10123000000
1517-10123456789:5:-10123000000
1518+10123456789:9:+10123456700
1519-10123456789:9:-10123456700
1520+101234500:6:+101234000
1521-101234500:6:-101234000
1522#+101234500:-4:+101234000
1523#-101234500:-4:-101234000
1524$round_mode('zero')
1525+20123456789:5:+20123000000
1526-20123456789:5:-20123000000
1527+20123456789:9:+20123456800
1528-20123456789:9:-20123456800
1529+201234500:6:+201234000
1530-201234500:6:-201234000
1531#+201234500:-4:+201234000
1532#-201234500:-4:-201234000
1533+12345000:4:12340000
1534-12345000:4:-12340000
1535$round_mode('+inf')
1536+30123456789:5:+30123000000
1537-30123456789:5:-30123000000
1538+30123456789:9:+30123456800
1539-30123456789:9:-30123456800
1540+301234500:6:+301235000
1541-301234500:6:-301234000
1542#+301234500:-4:+301235000
1543#-301234500:-4:-301234000
1544+12345000:4:12350000
1545-12345000:4:-12340000
1546$round_mode('-inf')
1547+40123456789:5:+40123000000
1548-40123456789:5:-40123000000
1549+40123456789:9:+40123456800
1550-40123456789:9:-40123456800
1551+401234500:6:+401234000
1552+401234500:6:+401234000
1553#-401234500:-4:-401235000
1554#-401234500:-4:-401235000
1555+12345000:4:12340000
1556-12345000:4:-12350000
1557$round_mode('odd')
1558+50123456789:5:+50123000000
1559-50123456789:5:-50123000000
1560+50123456789:9:+50123456800
1561-50123456789:9:-50123456800
1562+501234500:6:+501235000
1563-501234500:6:-501235000
1564#+501234500:-4:+501235000
1565#-501234500:-4:-501235000
1566+12345000:4:12350000
1567-12345000:4:-12350000
1568$round_mode('even')
1569+60123456789:5:+60123000000
1570-60123456789:5:-60123000000
1571+60123456789:9:+60123456800
1572-60123456789:9:-60123456800
1573+601234500:6:+601234000
1574-601234500:6:-601234000
1575#+601234500:-4:+601234000
1576#-601234500:-4:-601234000
1577#-601234500:-9:0
1578#-501234500:-9:0
1579#-601234500:-8:0
1580#-501234500:-8:0
1581+1234567:7:1234567
1582+1234567:6:1234570
1583+12345000:4:12340000
1584-12345000:4:-12340000
1585&is_zero
15860:1
1587NaNzero:0
1588+inf:0
1589-inf:0
1590123:0
1591-1:0
15921:0
1593&is_one
15940:0
1595NaNone:0
1596+inf:0
1597-inf:0
15981:1
15992:0
1600-1:0
1601-2:0
1602# floor and ceil tests are pretty pointless in integer space...but play safe
1603&bfloor
16040:0
1605NaNfloor:NaN
1606+inf:inf
1607-inf:-inf
1608-1:-1
1609-2:-2
16102:2
16113:3
1612abc:NaN
1613&bceil
1614NaNceil:NaN
1615+inf:inf
1616-inf:-inf
16170:0
1618-1:-1
1619-2:-2
16202:2
16213:3
1622abc:NaN
1623&as_hex
1624128:0x80
1625-128:-0x80
16260:0x0
1627-0:0x0
16281:0x1
16290x123456789123456789:0x123456789123456789
1630+inf:inf
1631-inf:-inf
1632NaNas_hex:NaN
1633&as_bin
1634128:0b10000000
1635-128:-0b10000000
16360:0b0
1637-0:0b0
16381:0b1
16390b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1640+inf:inf
1641-inf:-inf
1642NaNas_bin:NaN