cleanup's
[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 {
d614cd8b 43 chomp;
6854fd01 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;";
d614cd8b 166 } elsif( $f eq "bmodinv") {
167 $try .= "\$x->bmodinv(\$y);";
6854fd01 168 }elsif ($f eq "digit"){
56b9c951 169 $try .= "\$x->digit(\$y);";
d614cd8b 170 } else {
171 $try .= "\$z = $class->new(\"$args[2]\");";
172
173 # Functions with three arguments
174 if( $f eq "bmodpow") {
175 $try .= "\$x->bmodpow(\$y,\$z);";
176 } else { warn "Unknown op '$f'"; }
177 }
61f5c3f5 178 } # end else all other ops
179
180 $ans1 = eval $try;
181 # convert hex/binary targets to decimal
182 if ($ans =~ /^(0x0x|0b0b)/)
183 {
184 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 185 }
61f5c3f5 186 if ($ans eq "")
187 {
188 ok_undef ($ans1);
189 }
190 else
191 {
192 # print "try: $try ans: $ans1 $ans\n";
193 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
b3abae2a 194 ok (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 195 }
61f5c3f5 196 # check internal state of number objects
197 is_valid($ans1,$f) if ref $ans1;
6854fd01 198 } # endwhile data tests
199close DATA;
200
201# test some more
202@a = ();
203for (my $i = 1; $i < 10; $i++)
204 {
205 push @a, $i;
206 }
207ok "@a", "1 2 3 4 5 6 7 8 9";
208
209# test whether self-multiplication works correctly (result is 2**64)
210$try = "\$x = $class->new('4294967296');";
211$try .= '$a = $x->bmul($x);';
212$ans1 = eval $try;
213print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
214# test self-pow
215$try = "\$x = $class->new(10);";
216$try .= '$a = $x->bpow($x);';
217$ans1 = eval $try;
218print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
219
220# test whether op destroys args or not (should better not)
221
222$x = $class->new(3);
223$y = $class->new(4);
224$z = $x & $y;
225ok ($x,3);
226ok ($y,4);
227ok ($z,0);
228$z = $x | $y;
229ok ($x,3);
230ok ($y,4);
231ok ($z,7);
232$x = $class->new(1);
233$y = $class->new(2);
234$z = $x | $y;
235ok ($x,1);
236ok ($y,2);
237ok ($z,3);
238
239$x = $class->new(5);
240$y = $class->new(4);
241$z = $x ^ $y;
242ok ($x,5);
243ok ($y,4);
244ok ($z,1);
245
246$x = $class->new(-5); $y = -$x;
247ok ($x, -5);
248
249$x = $class->new(-5); $y = abs($x);
250ok ($x, -5);
251
252# check whether overloading cmp works
253$try = "\$x = $class->new(0);";
254$try .= "\$y = 10;";
255$try .= "'false' if \$x ne \$y;";
256$ans = eval $try;
257print "# For '$try'\n" if (!ok "$ans" , "false" );
258
259# we cant test for working cmpt with other objects here, we would need a dummy
260# object with stringify overload for this. see Math::String tests as example
261
262###############################################################################
6854fd01 263# check reversed order of arguments
027dc388 264
6854fd01 265$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
266$try .= "'ok' if \$x == 1024;"; $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 == 20;"; $ans = eval $try;
271print "# For '$try'\n" if (!ok "$ans" , "ok" );
272
273$try = "\$x = $class->new(10); \$x = 2 + \$x;";
274$try .= "'ok' if \$x == 12;"; $ans = eval $try;
275print "# For '$try'\n" if (!ok "$ans" , "ok" );
276
277$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
278$try .= "'ok' if \$x == -8;"; $ans = eval $try;
279print "# For '$try'\n" if (!ok "$ans" , "ok" );
280
281$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
282$try .= "'ok' if \$x == 2;"; $ans = eval $try;
283print "# For '$try'\n" if (!ok "$ans" , "ok" );
284
027dc388 285$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
286$try .= "'ok' if \$x == 2;"; $ans = eval $try;
287print "# For '$try'\n" if (!ok "$ans" , "ok" );
288
289$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
290$try .= "'ok' if \$x == 4;"; $ans = eval $try;
291print "# For '$try'\n" if (!ok "$ans" , "ok" );
292
293$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
294$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
295print "# For '$try'\n" if (!ok "$ans" , "ok" );
296
297$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
298$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
299print "# For '$try'\n" if (!ok "$ans" , "ok" );
300
6854fd01 301###############################################################################
302# check badd(4,5) form
303
304$try = "\$x = $class\->badd(4,5);";
305$try .= "'ok' if \$x == 9;";
306$ans = eval $try;
307print "# For '$try'\n" if (!ok "$ans" , "ok" );
308
309###############################################################################
310# check undefs: NOT DONE YET
311
312###############################################################################
313# bool
314
315$x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
316$x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
317
318###############################################################################
319# objectify()
320
321@args = Math::BigInt::objectify(2,4,5);
322ok (scalar @args,3); # $class, 4, 5
56b9c951 323ok ($args[0] =~ /^Math::BigInt/);
6854fd01 324ok ($args[1],4);
325ok ($args[2],5);
326
327@args = Math::BigInt::objectify(0,4,5);
328ok (scalar @args,3); # $class, 4, 5
56b9c951 329ok ($args[0] =~ /^Math::BigInt/);
6854fd01 330ok ($args[1],4);
331ok ($args[2],5);
332
333@args = Math::BigInt::objectify(2,4,5);
334ok (scalar @args,3); # $class, 4, 5
56b9c951 335ok ($args[0] =~ /^Math::BigInt/);
6854fd01 336ok ($args[1],4);
337ok ($args[2],5);
338
339@args = Math::BigInt::objectify(2,4,5,6,7);
340ok (scalar @args,5); # $class, 4, 5, 6, 7
56b9c951 341ok ($args[0] =~ /^Math::BigInt/);
6854fd01 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@args = Math::BigInt::objectify(2,$class,4,5,6,7);
348ok (scalar @args,5); # $class, 4, 5, 6, 7
349ok ($args[0],$class);
350ok ($args[1],4); ok (ref($args[1]),$args[0]);
351ok ($args[2],5); ok (ref($args[2]),$args[0]);
352ok ($args[3],6); ok (ref($args[3]),'');
353ok ($args[4],7); ok (ref($args[4]),'');
354
355###############################################################################
356# test for floating-point input (other tests in bnorm() below)
357
358$z = 1050000000000000; # may be int on systems with 64bit?
359$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
360$z = 1e+129; # definitely a float (may fail on UTS)
361# don't compare to $z, since some Perl versions stringify $z into something
362# like '1.e+129' or something equally ugly
363$x = $class->new($z); ok ($x->bsstr(),'1e+129');
364
365###############################################################################
366# prime number tests, also test for **= and length()
367# found on: http://www.utm.edu/research/primes/notes/by_year.html
368
369# ((2^148)-1)/17
370$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
371ok ($x,"20988936657440586486151264256610222593863921");
372ok ($x->length(),length "20988936657440586486151264256610222593863921");
373
374# MM7 = 2^127-1
375$x = $class->new(2); $x **= 127; $x--;
376ok ($x,"170141183460469231731687303715884105727");
377
378$x = $class->new('215960156869840440586892398248');
379($x,$y) = $x->length();
380ok ($x,30); ok ($y,0);
381
382$x = $class->new('1_000_000_000_000');
383($x,$y) = $x->length();
384ok ($x,13); ok ($y,0);
385
386# I am afraid the following is not yet possible due to slowness
387# Also, testing for 2 meg output is a bit hard ;)
388#$x = $class->new(2); $x **= 6972593; $x--;
389
390# 593573509*2^332162+1 has exactly 1,000,000 digits
391# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
392#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
393#ok ($x->length(),1_000_000);
394
395###############################################################################
396# inheritance and overriding of _swap
397
398$x = Math::Foo->new(5);
399$x = $x - 8; # 8 - 5 instead of 5-8
400ok ($x,3);
401ok (ref($x),'Math::Foo');
402
403$x = Math::Foo->new(5);
404$x = 8 - $x; # 5 - 8 instead of 8 - 5
405ok ($x,-3);
406ok (ref($x),'Math::Foo');
407
408###############################################################################
409# Test whether +inf eq inf
410# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
411# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
412# like 1e100000 crash on some platforms. So simple test for the string 'inf'
413$x = $class->new('+inf'); ok ($x,'inf');
414
415###############################################################################
416###############################################################################
394e6ffb 417# the followin tests only make sense with Math::BigInt::Calc or BareCalc
6854fd01 418
394e6ffb 419exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
6854fd01 420
421###############################################################################
422# check proper length of internal arrays
423
394e6ffb 424my $bl = $CL->_base_len();
6854fd01 425my $BASE = '9' x $bl;
426my $MAX = $BASE;
427$BASE++;
428
429$x = $class->new($MAX); is_valid($x); # f.i. 9999
430$x += 1; ok ($x,$BASE); is_valid($x); # 10000
431$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
432
433###############################################################################
434# check numify
435
436$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
437$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
61f5c3f5 438
439# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
440$x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
6854fd01 441$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
442$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
443ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
444
445###############################################################################
446# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
447
394e6ffb 448$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
449if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
450
451$x = $class->new($BASE+3); $x++;
452if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 453
394e6ffb 454# test for +0 instead of int():
455$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 456
457###############################################################################
56b9c951 458# test bug that $class->digit($string) did not work
459
460ok ($class->digit(123,2),1);
461
462###############################################################################
6854fd01 463# bug in sub where number with at least 6 trailing zeros after any op failed
464
394e6ffb 465$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 466ok ($z, 100000);
467ok ($x, 23456);
468
469###############################################################################
470# bug in shortcut in mul()
471
61f5c3f5 472# construct a number with a zero-hole of BASE_LEN_SMALL
473{
474 my @bl = $CL->_base_len(); my $bl = $bl[4];
475
476 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
477 $y = '1' x (2*$bl);
478 $x = $class->new($x)->bmul($y);
479 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
480 $y = ''; my $d = '';
481 for (my $i = 1; $i <= $bl; $i++)
482 {
483 $y .= $i; $d = $i.$d;
484 }
485 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
486 ok ($x,$y);
487
6854fd01 488
489###############################################################################
394e6ffb 490# see if mul shortcut for small numbers works
491
492$x = '9' x $bl;
493$x = $class->new($x);
494# 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
495ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
496
61f5c3f5 497 }
498
394e6ffb 499###############################################################################
6854fd01 500# bug with rest "-0" in div, causing further div()s to fail
501
394e6ffb 502$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 503
61f5c3f5 504ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 505
79c55733 506###############################################################################
56b9c951 507# bone/binf etc as plain calls (Lite failed them)
508
509ok ($class->bzero(),0);
510ok ($class->bone(),1);
511ok ($class->bone('+'),1);
512ok ($class->bone('-'),-1);
513ok ($class->bnan(),'NaN');
514ok ($class->binf(),'inf');
515ok ($class->binf('+'),'inf');
516ok ($class->binf('-'),'-inf');
517ok ($class->binf('-inf'),'-inf');
518
519###############################################################################
61f5c3f5 520# all tests done
6854fd01 521
5221;
523
524###############################################################################
61f5c3f5 525###############################################################################
6854fd01 526# Perl 5.005 does not like ok ($x,undef)
527
528sub ok_undef
529 {
530 my $x = shift;
531
532 ok (1,1) and return if !defined $x;
533 ok ($x,'undef');
534 }
535
536###############################################################################
537# sub to check validity of a BigInt internally, to ensure that no op leaves a
538# number object in an invalid state (f.i. "-0")
539
540sub is_valid
541 {
542 my ($x,$f) = @_;
543
544 my $e = 0; # error?
6854fd01 545
56b9c951 546 # allow the check to pass for all Lite, and all MBI and subclasses
547 # ok as reference?
548 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 549
56b9c951 550 if (ref($x) ne 'Math::BigInt::Lite')
551 {
552 # has ok sign?
553 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
554 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
555
556 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
557 $e = $CALC->_check($x->{value}) if $e eq '0';
558 }
6854fd01 559
560 # test done, see if error did crop up
561 ok (1,1), return if ($e eq '0');
562
027dc388 563 ok (1,$e." after op '$f'");
6854fd01 564 }
565
566__DATA__
027dc388 567&.=
5681234:-345:1234-345
569&+=
5701:2:3
571-1:-2:-3
572&-=
5731:2:-1
574-1:-2:1
575&*=
5762:3:6
577-1:5:-5
578&%=
579100:3:1
5808:9:8
581&/=
582100:3:33
583-8:2:-4
584&|=
5852:1:3
586&&=
5875:7:5
588&^=
5895:7:2
6854fd01 590&is_negative
5910:0
592-1:1
5931:0
594+inf:0
595-inf:1
596NaNneg:0
597&is_positive
5980:1
599-1:0
6001:1
601+inf:1
602-inf:0
603NaNneg:0
b3abae2a 604&is_int
605-inf:0
606+inf:0
607NaNis_int:0
6081:1
6090:1
610123e12:1
6854fd01 611&is_odd
612abc:0
6130:0
6141:1
6153:1
616-1:1
617-3:1
61810000001:1
61910000002:0
6202:0
b3abae2a 621120:0
622121:1
6854fd01 623&is_even
624abc:0
6250:1
6261:0
6273:0
628-1:0
629-3:0
63010000001:0
63110000002:1
6322:1
b3abae2a 633120:1
634121:0
6854fd01 635&bacmp
636+0:-0:0
637+0:+1:-1
638-1:+1:0
639+1:-1:0
640-1:+2:-1
641+2:-1:1
642-123456789:+987654321:-1
643+123456789:-987654321:-1
644+987654321:+123456789:1
645-987654321:+123456789:1
646-123:+4567889:-1
647# NaNs
648acmpNaN:123:
649123:acmpNaN:
650acmpNaN:acmpNaN:
651# infinity
652+inf:+inf:0
653-inf:-inf:0
654+inf:-inf:0
655-inf:+inf:0
656+inf:123:1
657-inf:123:1
658+inf:-123:1
659-inf:-123:1
660# return undef
661+inf:NaN:
662NaN:inf:
663-inf:NaN:
664NaN:-inf:
665&bnorm
666123:123
667# binary input
6680babc:NaN
6690b123:NaN
6700b0:0
671-0b0:0
672-0b1:-1
6730b0001:1
6740b001:1
6750b011:3
6760b101:5
61f5c3f5 6770b1001:9
6780b10001:17
6790b100001:33
6800b1000001:65
6810b10000001:129
6820b100000001:257
6830b1000000001:513
6840b10000000001:1025
6850b100000000001:2049
6860b1000000000001:4097
6870b10000000000001:8193
6880b100000000000001:16385
6890b1000000000000001:32769
6900b10000000000000001:65537
6910b100000000000000001:131073
6920b1000000000000000001:262145
6930b10000000000000000001:524289
6940b100000000000000000001:1048577
6950b1000000000000000000001:2097153
6960b10000000000000000000001:4194305
6970b100000000000000000000001:8388609
6980b1000000000000000000000001:16777217
6990b10000000000000000000000001:33554433
7000b100000000000000000000000001:67108865
7010b1000000000000000000000000001:134217729
7020b10000000000000000000000000001:268435457
7030b100000000000000000000000000001:536870913
7040b1000000000000000000000000000001:1073741825
7050b10000000000000000000000000000001:2147483649
7060b100000000000000000000000000000001:4294967297
7070b1000000000000000000000000000000001:8589934593
7080b10000000000000000000000000000000001:17179869185
6854fd01 7090b_101:NaN
7100b1_0_1:5
394e6ffb 7110b0_0_0_1:1
6854fd01 712# hex input
713-0x0:0
7140xabcdefgh:NaN
7150x1234:4660
7160xabcdef:11259375
717-0xABCDEF:-11259375
718-0x1234:-4660
7190x12345678:305419896
7200x1_2_3_4_56_78:305419896
394e6ffb 7210xa_b_c_d_e_f:11259375
6854fd01 7220x_123:NaN
61f5c3f5 7230x9:9
7240x11:17
7250x21:33
7260x41:65
7270x81:129
7280x101:257
7290x201:513
7300x401:1025
7310x801:2049
7320x1001:4097
7330x2001:8193
7340x4001:16385
7350x8001:32769
7360x10001:65537
7370x20001:131073
7380x40001:262145
7390x80001:524289
7400x100001:1048577
7410x200001:2097153
7420x400001:4194305
7430x800001:8388609
7440x1000001:16777217
7450x2000001:33554433
7460x4000001:67108865
7470x8000001:134217729
7480x10000001:268435457
7490x20000001:536870913
7500x40000001:1073741825
7510x80000001:2147483649
7520x100000001:4294967297
7530x200000001:8589934593
7540x400000001:17179869185
7550x800000001:34359738369
6854fd01 756# inf input
757inf:inf
758+inf:inf
759-inf:-inf
7600inf:NaN
027dc388 761# abnormal input
6854fd01 762:NaN
763abc:NaN
764 1 a:NaN
7651bcd2:NaN
76611111b:NaN
767+1z:NaN
768-1z:NaN
027dc388 769# only one underscore between two digits
770_123:NaN
771_123_:NaN
772123_:NaN
7731__23:NaN
7741E1__2:NaN
7751_E12:NaN
7761E_12:NaN
7771_E_12:NaN
778+_1E12:NaN
779+0_1E2:100
780+0_0_1E2:100
781-0_0_1E2:-100
782-0_0_1E+0_0_2:-100
783E1:NaN
784E23:NaN
7851.23E1:NaN
7861.23E-1:NaN
787# bug with two E's in number beeing valid
7881e2e3:NaN
7891e2r:NaN
7901e2.0:NaN
61f5c3f5 791# leading zeros
792012:12
7930123:123
79401234:1234
795012345:12345
7960123456:123456
79701234567:1234567
798012345678:12345678
7990123456789:123456789
80001234567891:1234567891
801012345678912:12345678912
8020123456789123:123456789123
80301234567891234:1234567891234
027dc388 804# normal input
6854fd01 8050:0
806+0:0
807+00:0
808+000:0
809000000000000000000:0
810-0:0
811-0000:0
812+1:1
813+01:1
814+001:1
815+00000100000:100000
816123456789:123456789
817-1:-1
818-01:-1
819-001:-1
820-123456789:-123456789
821-00000100000:-100000
8221_2_3:123
6854fd01 82310000000000E-1_0:1
8241E2:100
8251E1:10
8261E0:1
6854fd01 8271.23E2:123
6854fd01 828100E-1:10
829# floating point input
027dc388 830# .2e2:20
8311.E3:1000
6854fd01 8321.01E2:101
8331010E-1:101
834-1010E0:-1010
835-1010E1:-10100
027dc388 8361234.00:1234
837# non-integer numbers
6854fd01 838-1010E-2:NaN
839-1.01E+1:NaN
840-1.01E-1:NaN
6854fd01 841&bnan
8421:NaN
8432:NaN
844abc:NaN
845&bone
61f5c3f5 8462:+:1
6854fd01 8472:-:-1
848boneNaN:-:-1
61f5c3f5 849boneNaN:+:1
8502:abc:1
8513::1
6854fd01 852&binf
8531:+:inf
8542:-:-inf
8553:abc:inf
027dc388 856&is_nan
857123:0
858abc:1
859NaN:1
860-123:0
6854fd01 861&is_inf
862+inf::1
863-inf::1
864abc::0
8651::0
866NaN::0
867-1::0
868+inf:-:0
869+inf:+:1
870-inf:-:1
871-inf:+:0
79c55733 872-inf:-inf:1
873-inf:+inf:0
874+inf:-inf:0
875+inf:+inf:1
6854fd01 876# it must be exactly /^[+-]inf$/
877+infinity::0
878-infinity::0
879&blsft
880abc:abc:NaN
61f5c3f5 881+2:+2:8
882+1:+32:4294967296
883+1:+48:281474976710656
6854fd01 884+8:-2:NaN
885# excercise base 10
886+12345:4:10:123450000
887-1234:0:10:-1234
61f5c3f5 888+1234:0:10:1234
6854fd01 889+2:2:10:200
890+12:2:10:1200
891+1234:-3:10:NaN
8921234567890123:12:10:1234567890123000000000000
b3abae2a 893-3:1:2:-6
894-5:1:2:-10
895-2:1:2:-4
896-102533203:1:2:-205066406
6854fd01 897&brsft
898abc:abc:NaN
61f5c3f5 899+8:+2:2
900+4294967296:+32:1
901+281474976710656:+48:1
6854fd01 902+2:-2:NaN
903# excercise base 10
904-1234:0:10:-1234
61f5c3f5 905+1234:0:10:1234
6854fd01 906+200:2:10:2
907+1234:3:10:1
908+1234:2:10:12
909+1234:-3:10:NaN
910310000:4:10:31
91112300000:5:10:123
9121230000000000:10:10:123
91309876123456789067890:12:10:9876123
9141234561234567890123:13:10:123456
b3abae2a 915820265627:1:2:410132813
916# test shifting negative numbers in base 2
917-15:1:2:-8
918-14:1:2:-7
919-13:1:2:-7
920-12:1:2:-6
921-11:1:2:-6
922-10:1:2:-5
923-9:1:2:-5
924-8:1:2:-4
925-7:1:2:-4
926-6:1:2:-3
927-5:1:2:-3
928-4:1:2:-2
929-3:1:2:-2
930-2:1:2:-1
931-1:1:2:-1
932-1640531254:2:2:-410132814
933-1640531254:1:2:-820265627
934-820265627:1:2:-410132814
935-205066405:1:2:-102533203
6854fd01 936&bsstr
9371e+34:1e+34
938123.456E3:123456e+0
939100:1e+2
940abc:NaN
941&bneg
942bnegNaN:NaN
943+inf:-inf
944-inf:inf
945abd:NaN
61f5c3f5 9460:0
9471:-1
948-1:1
6854fd01 949+123456789:-123456789
61f5c3f5 950-123456789:123456789
6854fd01 951&babs
952babsNaN:NaN
953+inf:inf
954-inf:inf
61f5c3f5 9550:0
9561:1
957-1:1
958+123456789:123456789
959-123456789:123456789
6854fd01 960&bcmp
961bcmpNaN:bcmpNaN:
61f5c3f5 962bcmpNaN:0:
9630:bcmpNaN:
9640:0:0
965-1:0:-1
9660:-1:1
9671:0:1
9680:1:-1
969-1:1:-1
9701:-1:1
6854fd01 971-1:-1:0
61f5c3f5 9721:1:0
973123:123:0
974123:12:1
97512:123:-1
6854fd01 976-123:-123:0
977-123:-12:-1
978-12:-123:1
61f5c3f5 979123:124:-1
980124:123:1
6854fd01 981-123:-124:1
982-124:-123:-1
61f5c3f5 983100:5:1
984-123456789:987654321:-1
6854fd01 985+123456789:-987654321:1
61f5c3f5 986-987654321:123456789:-1
6854fd01 987-inf:5432112345:-1
988+inf:5432112345:1
989-inf:-5432112345:-1
990+inf:-5432112345:1
991+inf:+inf:0
992-inf:-inf:0
993+inf:-inf:1
994-inf:+inf:-1
9955:inf:-1
9965:inf:-1
997-5:-inf:1
998-5:-inf:1
999# return undef
1000+inf:NaN:
1001NaN:inf:
1002-inf:NaN:
1003NaN:-inf:
1004&binc
1005abc:NaN
1006+inf:inf
1007-inf:-inf
61f5c3f5 1008+0:1
1009+1:2
1010-1:0
6854fd01 1011&bdec
1012abc:NaN
1013+inf:inf
1014-inf:-inf
1015+0:-1
61f5c3f5 1016+1:0
6854fd01 1017-1:-2
1018&badd
1019abc:abc:NaN
61f5c3f5 1020abc:0:NaN
6854fd01 1021+0:abc:NaN
b3abae2a 1022+inf:-inf:NaN
1023-inf:+inf:NaN
6854fd01 1024+inf:+inf:inf
1025-inf:-inf:-inf
1026baddNaN:+inf:NaN
1027baddNaN:+inf:NaN
1028+inf:baddNaN:NaN
1029-inf:baddNaN:NaN
61f5c3f5 10300:0:0
10311:0:1
10320:1:1
10331:1:2
1034-1:0:-1
10350:-1:-1
6854fd01 1036-1:-1:-2
61f5c3f5 1037-1:+1:0
1038+1:-1:0
1039+9:+1:10
1040+99:+1:100
1041+999:+1:1000
1042+9999:+1:10000
1043+99999:+1:100000
1044+999999:+1:1000000
1045+9999999:+1:10000000
1046+99999999:+1:100000000
1047+999999999:+1:1000000000
1048+9999999999:+1:10000000000
1049+99999999999:+1:100000000000
1050+10:-1:9
1051+100:-1:99
1052+1000:-1:999
1053+10000:-1:9999
1054+100000:-1:99999
1055+1000000:-1:999999
1056+10000000:-1:9999999
1057+100000000:-1:99999999
1058+1000000000:-1:999999999
1059+10000000000:-1:9999999999
1060+123456789:987654321:1111111110
1061-123456789:987654321:864197532
6854fd01 1062-123456789:-987654321:-1111111110
1063+123456789:-987654321:-864197532
56b9c951 1064-1:10001:10000
1065-1:100001:100000
1066-1:1000001:1000000
1067-1:10000001:10000000
1068-1:100000001:100000000
1069-1:1000000001:1000000000
1070-1:10000000001:10000000000
1071-1:100000000001:100000000000
1072-1:1000000000001:1000000000000
1073-1:10000000000001:10000000000000
1074-1:-10001:-10002
1075-1:-100001:-100002
1076-1:-1000001:-1000002
1077-1:-10000001:-10000002
1078-1:-100000001:-100000002
1079-1:-1000000001:-1000000002
1080-1:-10000000001:-10000000002
1081-1:-100000000001:-100000000002
1082-1:-1000000000001:-1000000000002
1083-1:-10000000000001:-10000000000002
6854fd01 1084&bsub
1085abc:abc:NaN
1086abc:+0:NaN
1087+0:abc:NaN
1088+inf:-inf:inf
1089-inf:+inf:-inf
b3abae2a 1090+inf:+inf:NaN
1091-inf:-inf:NaN
61f5c3f5 1092+0:+0:0
1093+1:+0:1
6854fd01 1094+0:+1:-1
61f5c3f5 1095+1:+1:0
6854fd01 1096-1:+0:-1
61f5c3f5 1097+0:-1:1
1098-1:-1:0
6854fd01 1099-1:+1:-2
61f5c3f5 1100+1:-1:2
1101+9:+1:8
1102+99:+1:98
1103+999:+1:998
1104+9999:+1:9998
1105+99999:+1:99998
1106+999999:+1:999998
1107+9999999:+1:9999998
1108+99999999:+1:99999998
1109+999999999:+1:999999998
1110+9999999999:+1:9999999998
1111+99999999999:+1:99999999998
1112+10:-1:11
1113+100:-1:101
1114+1000:-1:1001
1115+10000:-1:10001
1116+100000:-1:100001
1117+1000000:-1:1000001
1118+10000000:-1:10000001
1119+100000000:-1:100000001
1120+1000000000:-1:1000000001
1121+10000000000:-1:10000000001
6854fd01 1122+123456789:+987654321:-864197532
1123-123456789:+987654321:-1111111110
61f5c3f5 1124-123456789:-987654321:864197532
1125+123456789:-987654321:1111111110
56b9c951 112610001:1:10000
1127100001:1:100000
11281000001:1:1000000
112910000001:1:10000000
1130100000001:1:100000000
11311000000001:1:1000000000
113210000000001:1:10000000000
1133100000000001:1:100000000000
11341000000000001:1:1000000000000
113510000000000001:1:10000000000000
113610001:-1:10002
1137100001:-1:100002
11381000001:-1:1000002
113910000001:-1:10000002
1140100000001:-1:100000002
11411000000001:-1:1000000002
114210000000001:-1:10000000002
1143100000000001:-1:100000000002
11441000000000001:-1:1000000000002
114510000000000001:-1:10000000000002
6854fd01 1146&bmul
1147abc:abc:NaN
1148abc:+0:NaN
1149+0:abc:NaN
1150NaNmul:+inf:NaN
1151NaNmul:-inf:NaN
1152-inf:NaNmul:NaN
1153+inf:NaNmul:NaN
1154+inf:+inf:inf
1155+inf:-inf:-inf
1156-inf:+inf:-inf
1157-inf:-inf:inf
61f5c3f5 1158+0:+0:0
1159+0:+1:0
1160+1:+0:0
1161+0:-1:0
1162-1:+0:0
1163123456789123456789:0:0
11640:123456789123456789:0
1165-1:-1:1
6854fd01 1166-1:+1:-1
1167+1:-1:-1
61f5c3f5 1168+1:+1:1
1169+2:+3:6
6854fd01 1170-2:+3:-6
1171+2:-3:-6
61f5c3f5 1172-2:-3:6
1173111:111:12321
117410101:10101:102030201
11751001001:1001001:1002003002001
1176100010001:100010001:10002000300020001
117710000100001:10000100001:100002000030000200001
117811111111111:9:99999999999
117922222222222:9:199999999998
118033333333333:9:299999999997
118144444444444:9:399999999996
118255555555555:9:499999999995
118366666666666:9:599999999994
118477777777777:9:699999999993
118588888888888:9:799999999992
118699999999999:9:899999999991
1187+25:+25:625
1188+12345:+12345:152399025
1189+99999:+11111:1111088889
6854fd01 11909999:10000:99990000
119199999:100000:9999900000
1192999999:1000000:999999000000
11939999999:10000000:99999990000000
119499999999:100000000:9999999900000000
1195999999999:1000000000:999999999000000000
11969999999999:10000000000:99999999990000000000
119799999999999:100000000000:9999999999900000000000
1198999999999999:1000000000000:999999999999000000000000
11999999999999999:10000000000000:99999999999990000000000000
120099999999999999:100000000000000:9999999999999900000000000000
1201999999999999999:1000000000000000:999999999999999000000000000000
12029999999999999999:10000000000000000:99999999999999990000000000000000
120399999999999999999:100000000000000000:9999999999999999900000000000000000
1204999999999999999999:1000000000000000000:999999999999999999000000000000000000
12059999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1206&bdiv-list
1207100:20:5,0
12084095:4095:1,0
1209-4095:-4095:1,0
12104095:-4095:-1,0
1211-4095:4095:-1,0
1212123:2:61,1
b3abae2a 12139:5:1,4
12149:4:2,1
6854fd01 1215# inf handling and general remainder
12165:8:0,5
12170:8:0,0
121811:2:5,1
121911:-2:-5,-1
1220-11:2:-5,1
1221# see table in documentation in MBI
12220:inf:0,0
12230:-inf:0,0
12245:inf:0,5
12255:-inf:0,5
1226-5:inf:0,-5
1227-5:-inf:0,-5
1228inf:5:inf,0
1229-inf:5:-inf,0
1230inf:-5:-inf,0
1231-inf:-5:inf,0
12325:5:1,0
1233-5:-5:1,0
b3abae2a 1234inf:inf:NaN,NaN
1235-inf:-inf:NaN,NaN
1236-inf:inf:NaN,NaN
1237inf:-inf:NaN,NaN
6854fd01 12388:0:inf,8
1239inf:0:inf,inf
1240# exceptions to reminder rule
1241-8:0:-inf,-8
1242-inf:0:-inf,-inf
12430:0:NaN,NaN
1244&bdiv
1245abc:abc:NaN
61f5c3f5 1246abc:1:NaN
12471:abc:NaN
12480:0:NaN
6854fd01 1249# inf handling (see table in doc)
12500:inf:0
12510:-inf:0
12525:inf:0
12535:-inf:0
1254-5:inf:0
1255-5:-inf:0
1256inf:5:inf
1257-inf:5:-inf
1258inf:-5:-inf
1259-inf:-5:inf
12605:5:1
1261-5:-5:1
b3abae2a 1262inf:inf:NaN
1263-inf:-inf:NaN
1264-inf:inf:NaN
1265inf:-inf:NaN
6854fd01 12668:0:inf
1267inf:0:inf
1268-8:0:-inf
1269-inf:0:-inf
12700:0:NaN
127111:2:5
1272-11:-2:5
1273-11:2:-5
127411:-2:-5
61f5c3f5 12750:1:0
12760:-1:0
12771:1:1
1278-1:-1:1
12791:-1:-1
1280-1:1:-1
12811:2:0
12822:1:2
12831:26:0
12841000000000:9:111111111
12852000000000:9:222222222
12863000000000:9:333333333
12874000000000:9:444444444
12885000000000:9:555555555
12896000000000:9:666666666
12907000000000:9:777777777
12918000000000:9:888888888
12929000000000:9:1000000000
129335500000:113:314159
129471000000:226:314159
1295106500000:339:314159
12961000000000:3:333333333
1297+10:+5:2
1298+100:+4:25
1299+1000:+8:125
1300+10000:+16:625
1301999999999999:9:111111111111
1302999999999999:99:10101010101
1303999999999999:999:1001001001
1304999999999999:9999:100010001
1305999999999999999:99999:10000100001
1306+1111088889:99999:11111
6854fd01 1307-5:-3:1
1308-5:3:-1
13094:3:1
13104:-3:-1
13111:3:0
13121:-3:0
1313-2:-3:0
1314-2:3:0
13158:3:2
1316-8:3:-2
131714:-3:-4
1318-14:3:-4
1319-14:-3:4
132014:3:4
1321# bug in Calc with '99999' vs $BASE-1
132210000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
d614cd8b 1323#&bmodinv
1324## format: number:modulus:result
1325## bmodinv Data errors
1326#abc:abc:NaN
1327#abc:5:NaN
1328#5:abc:NaN
1329## bmodinv Expected Results from normal use
1330#1:5:1
1331#3:5:2
1332#-2:5:2
1333#324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
1334## bmodinv Error cases / useless use of function
1335#3:-5:NaN
1336#inf:5:NaN
1337#&bmodpow
1338## format: number:exponent:modulus:result
1339## bmodpow Data errors
1340#abc:abc:abc:NaN
1341#5:abc:abc:NaN
1342#abc:5:abc:NaN
1343#abc:abc:5:NaN
1344#5:5:abc:NaN
1345#5:abc:5:NaN
1346#abc:5:5:NaN
1347## bmodpow Expected results
1348#0:0:2:1
1349#1:0:2:1
1350#0:0:1:0
1351#8:7:5032:3840
1352#8:-1:5033:4404
1353#98436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1354## bmodpow Error cases
1355#8:8:-5:NaN
1356#8:-1:16:NaN
1357#inf:5:13:NaN
1358#5:inf:13:NaN
6854fd01 1359&bmod
1360# inf handling, see table in doc
13610:inf:0
13620:-inf:0
13635:inf:5
13645:-inf:5
1365-5:inf:-5
1366-5:-inf:-5
1367inf:5:0
1368-inf:5:0
1369inf:-5:0
1370-inf:-5:0
13715:5:0
1372-5:-5:0
b3abae2a 1373inf:inf:NaN
1374-inf:-inf:NaN
1375-inf:inf:NaN
1376inf:-inf:NaN
6854fd01 13778:0:8
1378inf:0:inf
1379# exceptions to reminder rule
1380-inf:0:-inf
1381-8:0:-8
13820:0:NaN
1383abc:abc:NaN
61f5c3f5 1384abc:1:abc:NaN
13851:abc:NaN
13860:0:NaN
13870:1:0
13881:0:1
13890:-1:0
1390-1:0:-1
13911:1:0
1392-1:-1:0
13931:-1:0
1394-1:1:0
13951:2:1
13962:1:0
13971000000000:9:1
13982000000000:9:2
13993000000000:9:3
14004000000000:9:4
14015000000000:9:5
14026000000000:9:6
14037000000000:9:7
14048000000000:9:8
14059000000000:9:0
140635500000:113:33
140771000000:226:66
1408106500000:339:99
14091000000000:3:1
141010:5:0
1411100:4:0
14121000:8:0
141310000:16:0
1414999999999999:9:0
1415999999999999:99:0
1416999999999999:999:0
1417999999999999:9999:0
1418999999999999999:99999:0
1419-9:+5:1
6854fd01 1420+9:-5:-1
1421-9:-5:-4
1422-5:3:1
1423-2:3:1
14244:3:1
14251:3:1
1426-5:-3:-2
1427-2:-3:-2
14284:-3:-2
14291:-3:-2
14304095:4095:0
027dc388 1431100041000510123:3:0
1432152403346:12345:4321
b3abae2a 14339:5:4
28df3e88 1434# test shortcuts in Calc
1435# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
14361234:9:1
1437123456:9:3
143812345678:9:0
14391234567891:9:1
1440123456789123:9:6
144112345678912345:9:6
14421234567891234567:9:1
1443123456789123456789:9:0
14441234:10:4
1445123456:10:6
144612345678:10:8
14471234567891:10:1
1448123456789123:10:3
144912345678912345:10:5
14501234567891234567:10:7
1451123456789123456789:10:9
14521234:113:104
1453123456:113:60
145412345678:113:89
14551234567891:113:64
1456123456789123:113:95
145712345678912345:113:53
14581234567891234567:113:56
1459123456789123456789:113:39
6854fd01 1460&bgcd
1461abc:abc:NaN
1462abc:+0:NaN
1463+0:abc:NaN
61f5c3f5 1464+0:+0:0
1465+0:+1:1
1466+1:+0:1
1467+1:+1:1
1468+2:+3:1
1469+3:+2:1
1470-3:+2:1
1471100:625:25
14724096:81:1
14731034:804:2
147427:90:56:1
147527:90:54:9
6854fd01 1476&blcm
1477abc:abc:NaN
1478abc:+0:NaN
1479+0:abc:NaN
1480+0:+0:NaN
61f5c3f5 1481+1:+0:0
1482+0:+1:0
1483+27:+90:270
1484+1034:+804:415668
6854fd01 1485&band
1486abc:abc:NaN
1487abc:0:NaN
14880:abc:NaN
14891:2:0
14903:2:2
61f5c3f5 1491+8:+2:0
1492+281474976710656:0:0
1493+281474976710656:1:0
1494+281474976710656:+281474976710656:281474976710656
6854fd01 1495-2:-3:-4
1496-1:-1:-1
1497-6:-6:-6
1498-7:-4:-8
1499-7:4:0
1500-4:7:4
394e6ffb 1501# equal arguments are treated special, so also do some test with unequal ones
15020xFFFF:0xFFFF:0x0xFFFF
15030xFFFFFF:0xFFFFFF:0x0xFFFFFF
15040xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
15050xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
15060xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
15070xF0F0:0xF0F0:0x0xF0F0
15080x0F0F:0x0F0F:0x0x0F0F
15090xF0F0F0:0xF0F0F0:0x0xF0F0F0
15100x0F0F0F:0x0F0F0F:0x0x0F0F0F
15110xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
15120x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
15130xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
15140x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
15150xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
15160x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
15170x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1518&bior
1519abc:abc:NaN
1520abc:0:NaN
15210:abc:NaN
15221:2:3
61f5c3f5 1523+8:+2:10
1524+281474976710656:0:281474976710656
1525+281474976710656:1:281474976710657
1526+281474976710656:281474976710656:281474976710656
6854fd01 1527-2:-3:-1
1528-1:-1:-1
1529-6:-6:-6
1530-7:4:-3
1531-4:7:-1
394e6ffb 1532# equal arguments are treated special, so also do some test with unequal ones
15330xFFFF:0xFFFF:0x0xFFFF
15340xFFFFFF:0xFFFFFF:0x0xFFFFFF
15350xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
15360xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
15370xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
15380:0xFFFF:0x0xFFFF
15390:0xFFFFFF:0x0xFFFFFF
15400:0xFFFFFFFF:0x0xFFFFFFFF
15410:0xFFFFFFFFFF:0x0xFFFFFFFFFF
15420:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
15430xFFFF:0:0x0xFFFF
15440xFFFFFF:0:0x0xFFFFFF
15450xFFFFFFFF:0:0x0xFFFFFFFF
15460xFFFFFFFFFF:0:0x0xFFFFFFFFFF
15470xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
15480xF0F0:0xF0F0:0x0xF0F0
15490x0F0F:0x0F0F:0x0x0F0F
15500xF0F0:0x0F0F:0x0xFFFF
15510xF0F0F0:0xF0F0F0:0x0xF0F0F0
15520x0F0F0F:0x0F0F0F:0x0x0F0F0F
15530x0F0F0F:0xF0F0F0:0x0xFFFFFF
15540xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
15550x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
15560x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
15570xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
15580x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
15590x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
15600xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
15610x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
15620x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
15630x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1564&bxor
1565abc:abc:NaN
1566abc:0:NaN
15670:abc:NaN
15681:2:3
61f5c3f5 1569+8:+2:10
1570+281474976710656:0:281474976710656
1571+281474976710656:1:281474976710657
1572+281474976710656:281474976710656:0
6854fd01 1573-2:-3:3
1574-1:-1:0
1575-6:-6:0
1576-7:4:-3
1577-4:7:-5
15784:-7:-3
1579-4:-7:5
394e6ffb 1580# equal arguments are treated special, so also do some test with unequal ones
15810xFFFF:0xFFFF:0
15820xFFFFFF:0xFFFFFF:0
15830xFFFFFFFF:0xFFFFFFFF:0
15840xFFFFFFFFFF:0xFFFFFFFFFF:0
15850xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
15860:0xFFFF:0x0xFFFF
15870:0xFFFFFF:0x0xFFFFFF
15880:0xFFFFFFFF:0x0xFFFFFFFF
15890:0xFFFFFFFFFF:0x0xFFFFFFFFFF
15900:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
15910xFFFF:0:0x0xFFFF
15920xFFFFFF:0:0x0xFFFFFF
15930xFFFFFFFF:0:0x0xFFFFFFFF
15940xFFFFFFFFFF:0:0x0xFFFFFFFFFF
15950xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
15960xF0F0:0xF0F0:0
15970x0F0F:0x0F0F:0
15980xF0F0:0x0F0F:0x0xFFFF
15990xF0F0F0:0xF0F0F0:0
16000x0F0F0F:0x0F0F0F:0
16010x0F0F0F:0xF0F0F0:0x0xFFFFFF
16020xF0F0F0F0:0xF0F0F0F0:0
16030x0F0F0F0F:0x0F0F0F0F:0
16040x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
16050xF0F0F0F0F0:0xF0F0F0F0F0:0
16060x0F0F0F0F0F:0x0F0F0F0F0F:0
16070x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
16080xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
16090x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
16100x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1611&bnot
1612abc:NaN
1613+0:-1
1614+8:-9
1615+281474976710656:-281474976710657
1616-1:0
1617-2:1
1618-12:11
1619&digit
16200:0:0
162112:0:2
162212:1:1
1623123:0:3
1624123:1:2
1625123:2:1
1626123:-1:1
1627123:-2:2
1628123:-3:3
1629123456:0:6
1630123456:1:5
1631123456:2:4
1632123456:3:3
1633123456:4:2
1634123456:5:1
1635123456:-1:1
1636123456:-2:2
1637123456:-3:3
1638100000:-3:0
1639100000:0:0
1640100000:1:0
1641&mantissa
1642abc:NaN
16431e4:1
16442e0:2
1645123:123
1646-1:-1
1647-2:-2
1648+inf:inf
1649-inf:-inf
1650&exponent
1651abc:NaN
16521e4:4
16532e0:0
1654123:0
1655-1:0
1656-2:0
16570:1
1658+inf:inf
1659-inf:inf
1660&parts
1661abc:NaN,NaN
16621e4:1,4
16632e0:2,0
1664123:123,0
1665-1:-1,0
1666-2:-2,0
16670:0,1
1668+inf:inf,inf
1669-inf:-inf,inf
b3abae2a 1670&bfac
1671-1:NaN
1672NaNfac:NaN
1673+inf:NaN
1674-inf:NaN
16750:1
16761:1
16772:2
16783:6
16794:24
16805:120
16816:720
168210:3628800
168311:39916800
168412:479001600
6854fd01 1685&bpow
1686abc:12:NaN
168712:abc:NaN
16880:0:1
16890:1:0
16900:2:0
16910:-1:NaN
16920:-2:NaN
16931:0:1
16941:1:1
16951:2:1
16961:3:1
16971:-1:1
16981:-2:1
16991:-3:1
17002:0:1
17012:1:2
17022:2:4
17032:3:8
17043:3:27
17052:-1:NaN
1706-2:-1:NaN
17072:-2:NaN
1708-2:-2:NaN
1709+inf:1234500012:inf
1710-inf:1234500012:-inf
1711+inf:-12345000123:inf
1712-inf:-12345000123:-inf
1713# 1 ** -x => 1 / (1 ** x)
1714-1:0:1
1715-2:0:1
1716-1:1:-1
1717-1:2:1
1718-1:3:-1
1719-1:4:1
1720-1:5:-1
1721-1:-1:-1
1722-1:-2:1
1723-1:-3:-1
1724-1:-4:1
172510:2:100
172610:3:1000
172710:4:10000
172810:5:100000
172910:6:1000000
173010:7:10000000
173110:8:100000000
173210:9:1000000000
173310:20:100000000000000000000
1734123456:2:15241383936
1735&length
1736100:3
173710:2
17381:1
17390:1
174012345:5
174110000000000000000:17
1742-123:3
1743215960156869840440586892398248:30
1744&bsqrt
394e6ffb 1745145:12
6854fd01 1746144:12
394e6ffb 1747143:11
6854fd01 174816:4
394e6ffb 1749170:13
1750169:13
1751168:12
6854fd01 17524:2
394e6ffb 17533:1
6854fd01 17542:1
394e6ffb 17559:3
6854fd01 175612:3
1757256:16
1758100000000:10000
17594000000000000:2000000
394e6ffb 1760152399026:12345
1761152399025:12345
1762152399024:12344
6854fd01 17631:1
17640:0
1765-2:NaN
394e6ffb 1766-123:NaN
6854fd01 1767Nan:NaN
394e6ffb 1768+inf:NaN
6854fd01 1769&bround
1770$round_mode('trunc')
17710:12:0
1772NaNbround:12:NaN
1773+inf:12:inf
1774-inf:12:-inf
17751234:0:1234
17761234:2:1200
1777123456:4:123400
1778123456:5:123450
1779123456:6:123456
61f5c3f5 1780+10123456789:5:10123000000
6854fd01 1781-10123456789:5:-10123000000
61f5c3f5 1782+10123456789:9:10123456700
6854fd01 1783-10123456789:9:-10123456700
61f5c3f5 1784+101234500:6:101234000
6854fd01 1785-101234500:6:-101234000
61f5c3f5 1786#+101234500:-4:101234000
6854fd01 1787#-101234500:-4:-101234000
1788$round_mode('zero')
61f5c3f5 1789+20123456789:5:20123000000
6854fd01 1790-20123456789:5:-20123000000
61f5c3f5 1791+20123456789:9:20123456800
6854fd01 1792-20123456789:9:-20123456800
61f5c3f5 1793+201234500:6:201234000
6854fd01 1794-201234500:6:-201234000
61f5c3f5 1795#+201234500:-4:201234000
6854fd01 1796#-201234500:-4:-201234000
1797+12345000:4:12340000
1798-12345000:4:-12340000
1799$round_mode('+inf')
61f5c3f5 1800+30123456789:5:30123000000
6854fd01 1801-30123456789:5:-30123000000
61f5c3f5 1802+30123456789:9:30123456800
6854fd01 1803-30123456789:9:-30123456800
61f5c3f5 1804+301234500:6:301235000
6854fd01 1805-301234500:6:-301234000
61f5c3f5 1806#+301234500:-4:301235000
6854fd01 1807#-301234500:-4:-301234000
1808+12345000:4:12350000
1809-12345000:4:-12340000
1810$round_mode('-inf')
61f5c3f5 1811+40123456789:5:40123000000
6854fd01 1812-40123456789:5:-40123000000
61f5c3f5 1813+40123456789:9:40123456800
6854fd01 1814-40123456789:9:-40123456800
61f5c3f5 1815+401234500:6:401234000
1816+401234500:6:401234000
6854fd01 1817#-401234500:-4:-401235000
1818#-401234500:-4:-401235000
1819+12345000:4:12340000
1820-12345000:4:-12350000
1821$round_mode('odd')
61f5c3f5 1822+50123456789:5:50123000000
6854fd01 1823-50123456789:5:-50123000000
61f5c3f5 1824+50123456789:9:50123456800
6854fd01 1825-50123456789:9:-50123456800
61f5c3f5 1826+501234500:6:501235000
6854fd01 1827-501234500:6:-501235000
61f5c3f5 1828#+501234500:-4:501235000
6854fd01 1829#-501234500:-4:-501235000
1830+12345000:4:12350000
1831-12345000:4:-12350000
1832$round_mode('even')
61f5c3f5 1833+60123456789:5:60123000000
6854fd01 1834-60123456789:5:-60123000000
61f5c3f5 1835+60123456789:9:60123456800
6854fd01 1836-60123456789:9:-60123456800
61f5c3f5 1837+601234500:6:601234000
6854fd01 1838-601234500:6:-601234000
61f5c3f5 1839#+601234500:-4:601234000
6854fd01 1840#-601234500:-4:-601234000
1841#-601234500:-9:0
1842#-501234500:-9:0
1843#-601234500:-8:0
1844#-501234500:-8:0
1845+1234567:7:1234567
1846+1234567:6:1234570
1847+12345000:4:12340000
1848-12345000:4:-12340000
1849&is_zero
18500:1
1851NaNzero:0
1852+inf:0
1853-inf:0
1854123:0
1855-1:0
18561:0
1857&is_one
18580:0
1859NaNone:0
1860+inf:0
1861-inf:0
18621:1
18632:0
1864-1:0
1865-2:0
1866# floor and ceil tests are pretty pointless in integer space...but play safe
1867&bfloor
18680:0
1869NaNfloor:NaN
1870+inf:inf
1871-inf:-inf
1872-1:-1
1873-2:-2
18742:2
18753:3
1876abc:NaN
1877&bceil
1878NaNceil:NaN
1879+inf:inf
1880-inf:-inf
18810:0
1882-1:-1
1883-2:-2
18842:2
18853:3
1886abc:NaN
1887&as_hex
1888128:0x80
1889-128:-0x80
18900:0x0
1891-0:0x0
18921:0x1
18930x123456789123456789:0x123456789123456789
1894+inf:inf
1895-inf:-inf
1896NaNas_hex:NaN
1897&as_bin
1898128:0b10000000
1899-128:-0b10000000
19000:0b0
1901-0:0b0
19021:0b1
19030b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1904+inf:inf
1905-inf:-inf
1906NaNas_bin:NaN