lib/blib.t tweak for VMS
[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"){
56b9c951 167 $try .= "\$x->digit(\$y);";
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
56b9c951 314ok ($args[0] =~ /^Math::BigInt/);
6854fd01 315ok ($args[1],4);
316ok ($args[2],5);
317
318@args = Math::BigInt::objectify(0,4,5);
319ok (scalar @args,3); # $class, 4, 5
56b9c951 320ok ($args[0] =~ /^Math::BigInt/);
6854fd01 321ok ($args[1],4);
322ok ($args[2],5);
323
324@args = Math::BigInt::objectify(2,4,5);
325ok (scalar @args,3); # $class, 4, 5
56b9c951 326ok ($args[0] =~ /^Math::BigInt/);
6854fd01 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
56b9c951 332ok ($args[0] =~ /^Math::BigInt/);
6854fd01 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###############################################################################
56b9c951 449# test bug that $class->digit($string) did not work
450
451ok ($class->digit(123,2),1);
452
453###############################################################################
6854fd01 454# bug in sub where number with at least 6 trailing zeros after any op failed
455
394e6ffb 456$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 457ok ($z, 100000);
458ok ($x, 23456);
459
460###############################################################################
461# bug in shortcut in mul()
462
61f5c3f5 463# construct a number with a zero-hole of BASE_LEN_SMALL
464{
465 my @bl = $CL->_base_len(); my $bl = $bl[4];
466
467 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
468 $y = '1' x (2*$bl);
469 $x = $class->new($x)->bmul($y);
470 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
471 $y = ''; my $d = '';
472 for (my $i = 1; $i <= $bl; $i++)
473 {
474 $y .= $i; $d = $i.$d;
475 }
476 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
477 ok ($x,$y);
478
6854fd01 479
480###############################################################################
394e6ffb 481# see if mul shortcut for small numbers works
482
483$x = '9' x $bl;
484$x = $class->new($x);
485# 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
486ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
487
61f5c3f5 488 }
489
394e6ffb 490###############################################################################
6854fd01 491# bug with rest "-0" in div, causing further div()s to fail
492
394e6ffb 493$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 494
61f5c3f5 495ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 496
79c55733 497###############################################################################
56b9c951 498# bone/binf etc as plain calls (Lite failed them)
499
500ok ($class->bzero(),0);
501ok ($class->bone(),1);
502ok ($class->bone('+'),1);
503ok ($class->bone('-'),-1);
504ok ($class->bnan(),'NaN');
505ok ($class->binf(),'inf');
506ok ($class->binf('+'),'inf');
507ok ($class->binf('-'),'-inf');
508ok ($class->binf('-inf'),'-inf');
509
510###############################################################################
61f5c3f5 511# all tests done
6854fd01 512
5131;
514
515###############################################################################
61f5c3f5 516###############################################################################
6854fd01 517# Perl 5.005 does not like ok ($x,undef)
518
519sub ok_undef
520 {
521 my $x = shift;
522
523 ok (1,1) and return if !defined $x;
524 ok ($x,'undef');
525 }
526
527###############################################################################
528# sub to check validity of a BigInt internally, to ensure that no op leaves a
529# number object in an invalid state (f.i. "-0")
530
531sub is_valid
532 {
533 my ($x,$f) = @_;
534
535 my $e = 0; # error?
6854fd01 536
56b9c951 537 # allow the check to pass for all Lite, and all MBI and subclasses
538 # ok as reference?
539 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 540
56b9c951 541 if (ref($x) ne 'Math::BigInt::Lite')
542 {
543 # has ok sign?
544 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
545 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
546
547 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
548 $e = $CALC->_check($x->{value}) if $e eq '0';
549 }
6854fd01 550
551 # test done, see if error did crop up
552 ok (1,1), return if ($e eq '0');
553
027dc388 554 ok (1,$e." after op '$f'");
6854fd01 555 }
556
557__DATA__
027dc388 558&.=
5591234:-345:1234-345
560&+=
5611:2:3
562-1:-2:-3
563&-=
5641:2:-1
565-1:-2:1
566&*=
5672:3:6
568-1:5:-5
569&%=
570100:3:1
5718:9:8
572&/=
573100:3:33
574-8:2:-4
575&|=
5762:1:3
577&&=
5785:7:5
579&^=
5805:7:2
6854fd01 581&is_negative
5820:0
583-1:1
5841:0
585+inf:0
586-inf:1
587NaNneg:0
588&is_positive
5890:1
590-1:0
5911:1
592+inf:1
593-inf:0
594NaNneg:0
b3abae2a 595&is_int
596-inf:0
597+inf:0
598NaNis_int:0
5991:1
6000:1
601123e12:1
6854fd01 602&is_odd
603abc:0
6040:0
6051:1
6063:1
607-1:1
608-3:1
60910000001:1
61010000002:0
6112:0
b3abae2a 612120:0
613121:1
6854fd01 614&is_even
615abc:0
6160:1
6171:0
6183:0
619-1:0
620-3:0
62110000001:0
62210000002:1
6232:1
b3abae2a 624120:1
625121:0
6854fd01 626&bacmp
627+0:-0:0
628+0:+1:-1
629-1:+1:0
630+1:-1:0
631-1:+2:-1
632+2:-1:1
633-123456789:+987654321:-1
634+123456789:-987654321:-1
635+987654321:+123456789:1
636-987654321:+123456789:1
637-123:+4567889:-1
638# NaNs
639acmpNaN:123:
640123:acmpNaN:
641acmpNaN:acmpNaN:
642# infinity
643+inf:+inf:0
644-inf:-inf:0
645+inf:-inf:0
646-inf:+inf:0
647+inf:123:1
648-inf:123:1
649+inf:-123:1
650-inf:-123:1
651# return undef
652+inf:NaN:
653NaN:inf:
654-inf:NaN:
655NaN:-inf:
656&bnorm
657123:123
658# binary input
6590babc:NaN
6600b123:NaN
6610b0:0
662-0b0:0
663-0b1:-1
6640b0001:1
6650b001:1
6660b011:3
6670b101:5
61f5c3f5 6680b1001:9
6690b10001:17
6700b100001:33
6710b1000001:65
6720b10000001:129
6730b100000001:257
6740b1000000001:513
6750b10000000001:1025
6760b100000000001:2049
6770b1000000000001:4097
6780b10000000000001:8193
6790b100000000000001:16385
6800b1000000000000001:32769
6810b10000000000000001:65537
6820b100000000000000001:131073
6830b1000000000000000001:262145
6840b10000000000000000001:524289
6850b100000000000000000001:1048577
6860b1000000000000000000001:2097153
6870b10000000000000000000001:4194305
6880b100000000000000000000001:8388609
6890b1000000000000000000000001:16777217
6900b10000000000000000000000001:33554433
6910b100000000000000000000000001:67108865
6920b1000000000000000000000000001:134217729
6930b10000000000000000000000000001:268435457
6940b100000000000000000000000000001:536870913
6950b1000000000000000000000000000001:1073741825
6960b10000000000000000000000000000001:2147483649
6970b100000000000000000000000000000001:4294967297
6980b1000000000000000000000000000000001:8589934593
6990b10000000000000000000000000000000001:17179869185
6854fd01 7000b_101:NaN
7010b1_0_1:5
394e6ffb 7020b0_0_0_1:1
6854fd01 703# hex input
704-0x0:0
7050xabcdefgh:NaN
7060x1234:4660
7070xabcdef:11259375
708-0xABCDEF:-11259375
709-0x1234:-4660
7100x12345678:305419896
7110x1_2_3_4_56_78:305419896
394e6ffb 7120xa_b_c_d_e_f:11259375
6854fd01 7130x_123:NaN
61f5c3f5 7140x9:9
7150x11:17
7160x21:33
7170x41:65
7180x81:129
7190x101:257
7200x201:513
7210x401:1025
7220x801:2049
7230x1001:4097
7240x2001:8193
7250x4001:16385
7260x8001:32769
7270x10001:65537
7280x20001:131073
7290x40001:262145
7300x80001:524289
7310x100001:1048577
7320x200001:2097153
7330x400001:4194305
7340x800001:8388609
7350x1000001:16777217
7360x2000001:33554433
7370x4000001:67108865
7380x8000001:134217729
7390x10000001:268435457
7400x20000001:536870913
7410x40000001:1073741825
7420x80000001:2147483649
7430x100000001:4294967297
7440x200000001:8589934593
7450x400000001:17179869185
7460x800000001:34359738369
6854fd01 747# inf input
748inf:inf
749+inf:inf
750-inf:-inf
7510inf:NaN
027dc388 752# abnormal input
6854fd01 753:NaN
754abc:NaN
755 1 a:NaN
7561bcd2:NaN
75711111b:NaN
758+1z:NaN
759-1z:NaN
027dc388 760# only one underscore between two digits
761_123:NaN
762_123_:NaN
763123_:NaN
7641__23:NaN
7651E1__2:NaN
7661_E12:NaN
7671E_12:NaN
7681_E_12:NaN
769+_1E12:NaN
770+0_1E2:100
771+0_0_1E2:100
772-0_0_1E2:-100
773-0_0_1E+0_0_2:-100
774E1:NaN
775E23:NaN
7761.23E1:NaN
7771.23E-1:NaN
778# bug with two E's in number beeing valid
7791e2e3:NaN
7801e2r:NaN
7811e2.0:NaN
61f5c3f5 782# leading zeros
783012:12
7840123:123
78501234:1234
786012345:12345
7870123456:123456
78801234567:1234567
789012345678:12345678
7900123456789:123456789
79101234567891:1234567891
792012345678912:12345678912
7930123456789123:123456789123
79401234567891234:1234567891234
027dc388 795# normal input
6854fd01 7960:0
797+0:0
798+00:0
799+000:0
800000000000000000000:0
801-0:0
802-0000:0
803+1:1
804+01:1
805+001:1
806+00000100000:100000
807123456789:123456789
808-1:-1
809-01:-1
810-001:-1
811-123456789:-123456789
812-00000100000:-100000
8131_2_3:123
6854fd01 81410000000000E-1_0:1
8151E2:100
8161E1:10
8171E0:1
6854fd01 8181.23E2:123
6854fd01 819100E-1:10
820# floating point input
027dc388 821# .2e2:20
8221.E3:1000
6854fd01 8231.01E2:101
8241010E-1:101
825-1010E0:-1010
826-1010E1:-10100
027dc388 8271234.00:1234
828# non-integer numbers
6854fd01 829-1010E-2:NaN
830-1.01E+1:NaN
831-1.01E-1:NaN
6854fd01 832&bnan
8331:NaN
8342:NaN
835abc:NaN
836&bone
61f5c3f5 8372:+:1
6854fd01 8382:-:-1
839boneNaN:-:-1
61f5c3f5 840boneNaN:+:1
8412:abc:1
8423::1
6854fd01 843&binf
8441:+:inf
8452:-:-inf
8463:abc:inf
027dc388 847&is_nan
848123:0
849abc:1
850NaN:1
851-123:0
6854fd01 852&is_inf
853+inf::1
854-inf::1
855abc::0
8561::0
857NaN::0
858-1::0
859+inf:-:0
860+inf:+:1
861-inf:-:1
862-inf:+:0
79c55733 863-inf:-inf:1
864-inf:+inf:0
865+inf:-inf:0
866+inf:+inf:1
6854fd01 867# it must be exactly /^[+-]inf$/
868+infinity::0
869-infinity::0
870&blsft
871abc:abc:NaN
61f5c3f5 872+2:+2:8
873+1:+32:4294967296
874+1:+48:281474976710656
6854fd01 875+8:-2:NaN
876# excercise base 10
877+12345:4:10:123450000
878-1234:0:10:-1234
61f5c3f5 879+1234:0:10:1234
6854fd01 880+2:2:10:200
881+12:2:10:1200
882+1234:-3:10:NaN
8831234567890123:12:10:1234567890123000000000000
b3abae2a 884-3:1:2:-6
885-5:1:2:-10
886-2:1:2:-4
887-102533203:1:2:-205066406
6854fd01 888&brsft
889abc:abc:NaN
61f5c3f5 890+8:+2:2
891+4294967296:+32:1
892+281474976710656:+48:1
6854fd01 893+2:-2:NaN
894# excercise base 10
895-1234:0:10:-1234
61f5c3f5 896+1234:0:10:1234
6854fd01 897+200:2:10:2
898+1234:3:10:1
899+1234:2:10:12
900+1234:-3:10:NaN
901310000:4:10:31
90212300000:5:10:123
9031230000000000:10:10:123
90409876123456789067890:12:10:9876123
9051234561234567890123:13:10:123456
b3abae2a 906820265627:1:2:410132813
907# test shifting negative numbers in base 2
908-15:1:2:-8
909-14:1:2:-7
910-13:1:2:-7
911-12:1:2:-6
912-11:1:2:-6
913-10:1:2:-5
914-9:1:2:-5
915-8:1:2:-4
916-7:1:2:-4
917-6:1:2:-3
918-5:1:2:-3
919-4:1:2:-2
920-3:1:2:-2
921-2:1:2:-1
922-1:1:2:-1
923-1640531254:2:2:-410132814
924-1640531254:1:2:-820265627
925-820265627:1:2:-410132814
926-205066405:1:2:-102533203
6854fd01 927&bsstr
9281e+34:1e+34
929123.456E3:123456e+0
930100:1e+2
931abc:NaN
932&bneg
933bnegNaN:NaN
934+inf:-inf
935-inf:inf
936abd:NaN
61f5c3f5 9370:0
9381:-1
939-1:1
6854fd01 940+123456789:-123456789
61f5c3f5 941-123456789:123456789
6854fd01 942&babs
943babsNaN:NaN
944+inf:inf
945-inf:inf
61f5c3f5 9460:0
9471:1
948-1:1
949+123456789:123456789
950-123456789:123456789
6854fd01 951&bcmp
952bcmpNaN:bcmpNaN:
61f5c3f5 953bcmpNaN:0:
9540:bcmpNaN:
9550:0:0
956-1:0:-1
9570:-1:1
9581:0:1
9590:1:-1
960-1:1:-1
9611:-1:1
6854fd01 962-1:-1:0
61f5c3f5 9631:1:0
964123:123:0
965123:12:1
96612:123:-1
6854fd01 967-123:-123:0
968-123:-12:-1
969-12:-123:1
61f5c3f5 970123:124:-1
971124:123:1
6854fd01 972-123:-124:1
973-124:-123:-1
61f5c3f5 974100:5:1
975-123456789:987654321:-1
6854fd01 976+123456789:-987654321:1
61f5c3f5 977-987654321:123456789:-1
6854fd01 978-inf:5432112345:-1
979+inf:5432112345:1
980-inf:-5432112345:-1
981+inf:-5432112345:1
982+inf:+inf:0
983-inf:-inf:0
984+inf:-inf:1
985-inf:+inf:-1
9865:inf:-1
9875:inf:-1
988-5:-inf:1
989-5:-inf:1
990# return undef
991+inf:NaN:
992NaN:inf:
993-inf:NaN:
994NaN:-inf:
995&binc
996abc:NaN
997+inf:inf
998-inf:-inf
61f5c3f5 999+0:1
1000+1:2
1001-1:0
6854fd01 1002&bdec
1003abc:NaN
1004+inf:inf
1005-inf:-inf
1006+0:-1
61f5c3f5 1007+1:0
6854fd01 1008-1:-2
1009&badd
1010abc:abc:NaN
61f5c3f5 1011abc:0:NaN
6854fd01 1012+0:abc:NaN
b3abae2a 1013+inf:-inf:NaN
1014-inf:+inf:NaN
6854fd01 1015+inf:+inf:inf
1016-inf:-inf:-inf
1017baddNaN:+inf:NaN
1018baddNaN:+inf:NaN
1019+inf:baddNaN:NaN
1020-inf:baddNaN:NaN
61f5c3f5 10210:0:0
10221:0:1
10230:1:1
10241:1:2
1025-1:0:-1
10260:-1:-1
6854fd01 1027-1:-1:-2
61f5c3f5 1028-1:+1:0
1029+1:-1:0
1030+9:+1:10
1031+99:+1:100
1032+999:+1:1000
1033+9999:+1:10000
1034+99999:+1:100000
1035+999999:+1:1000000
1036+9999999:+1:10000000
1037+99999999:+1:100000000
1038+999999999:+1:1000000000
1039+9999999999:+1:10000000000
1040+99999999999:+1:100000000000
1041+10:-1:9
1042+100:-1:99
1043+1000:-1:999
1044+10000:-1:9999
1045+100000:-1:99999
1046+1000000:-1:999999
1047+10000000:-1:9999999
1048+100000000:-1:99999999
1049+1000000000:-1:999999999
1050+10000000000:-1:9999999999
1051+123456789:987654321:1111111110
1052-123456789:987654321:864197532
6854fd01 1053-123456789:-987654321:-1111111110
1054+123456789:-987654321:-864197532
56b9c951 1055-1:10001:10000
1056-1:100001:100000
1057-1:1000001:1000000
1058-1:10000001:10000000
1059-1:100000001:100000000
1060-1:1000000001:1000000000
1061-1:10000000001:10000000000
1062-1:100000000001:100000000000
1063-1:1000000000001:1000000000000
1064-1:10000000000001:10000000000000
1065-1:-10001:-10002
1066-1:-100001:-100002
1067-1:-1000001:-1000002
1068-1:-10000001:-10000002
1069-1:-100000001:-100000002
1070-1:-1000000001:-1000000002
1071-1:-10000000001:-10000000002
1072-1:-100000000001:-100000000002
1073-1:-1000000000001:-1000000000002
1074-1:-10000000000001:-10000000000002
6854fd01 1075&bsub
1076abc:abc:NaN
1077abc:+0:NaN
1078+0:abc:NaN
1079+inf:-inf:inf
1080-inf:+inf:-inf
b3abae2a 1081+inf:+inf:NaN
1082-inf:-inf:NaN
61f5c3f5 1083+0:+0:0
1084+1:+0:1
6854fd01 1085+0:+1:-1
61f5c3f5 1086+1:+1:0
6854fd01 1087-1:+0:-1
61f5c3f5 1088+0:-1:1
1089-1:-1:0
6854fd01 1090-1:+1:-2
61f5c3f5 1091+1:-1:2
1092+9:+1:8
1093+99:+1:98
1094+999:+1:998
1095+9999:+1:9998
1096+99999:+1:99998
1097+999999:+1:999998
1098+9999999:+1:9999998
1099+99999999:+1:99999998
1100+999999999:+1:999999998
1101+9999999999:+1:9999999998
1102+99999999999:+1:99999999998
1103+10:-1:11
1104+100:-1:101
1105+1000:-1:1001
1106+10000:-1:10001
1107+100000:-1:100001
1108+1000000:-1:1000001
1109+10000000:-1:10000001
1110+100000000:-1:100000001
1111+1000000000:-1:1000000001
1112+10000000000:-1:10000000001
6854fd01 1113+123456789:+987654321:-864197532
1114-123456789:+987654321:-1111111110
61f5c3f5 1115-123456789:-987654321:864197532
1116+123456789:-987654321:1111111110
56b9c951 111710001:1:10000
1118100001:1:100000
11191000001:1:1000000
112010000001:1:10000000
1121100000001:1:100000000
11221000000001:1:1000000000
112310000000001:1:10000000000
1124100000000001:1:100000000000
11251000000000001:1:1000000000000
112610000000000001:1:10000000000000
112710001:-1:10002
1128100001:-1:100002
11291000001:-1:1000002
113010000001:-1:10000002
1131100000001:-1:100000002
11321000000001:-1:1000000002
113310000000001:-1:10000000002
1134100000000001:-1:100000000002
11351000000000001:-1:1000000000002
113610000000000001:-1:10000000000002
6854fd01 1137&bmul
1138abc:abc:NaN
1139abc:+0:NaN
1140+0:abc:NaN
1141NaNmul:+inf:NaN
1142NaNmul:-inf:NaN
1143-inf:NaNmul:NaN
1144+inf:NaNmul:NaN
1145+inf:+inf:inf
1146+inf:-inf:-inf
1147-inf:+inf:-inf
1148-inf:-inf:inf
61f5c3f5 1149+0:+0:0
1150+0:+1:0
1151+1:+0:0
1152+0:-1:0
1153-1:+0:0
1154123456789123456789:0:0
11550:123456789123456789:0
1156-1:-1:1
6854fd01 1157-1:+1:-1
1158+1:-1:-1
61f5c3f5 1159+1:+1:1
1160+2:+3:6
6854fd01 1161-2:+3:-6
1162+2:-3:-6
61f5c3f5 1163-2:-3:6
1164111:111:12321
116510101:10101:102030201
11661001001:1001001:1002003002001
1167100010001:100010001:10002000300020001
116810000100001:10000100001:100002000030000200001
116911111111111:9:99999999999
117022222222222:9:199999999998
117133333333333:9:299999999997
117244444444444:9:399999999996
117355555555555:9:499999999995
117466666666666:9:599999999994
117577777777777:9:699999999993
117688888888888:9:799999999992
117799999999999:9:899999999991
1178+25:+25:625
1179+12345:+12345:152399025
1180+99999:+11111:1111088889
6854fd01 11819999:10000:99990000
118299999:100000:9999900000
1183999999:1000000:999999000000
11849999999:10000000:99999990000000
118599999999:100000000:9999999900000000
1186999999999:1000000000:999999999000000000
11879999999999:10000000000:99999999990000000000
118899999999999:100000000000:9999999999900000000000
1189999999999999:1000000000000:999999999999000000000000
11909999999999999:10000000000000:99999999999990000000000000
119199999999999999:100000000000000:9999999999999900000000000000
1192999999999999999:1000000000000000:999999999999999000000000000000
11939999999999999999:10000000000000000:99999999999999990000000000000000
119499999999999999999:100000000000000000:9999999999999999900000000000000000
1195999999999999999999:1000000000000000000:999999999999999999000000000000000000
11969999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1197&bdiv-list
1198100:20:5,0
11994095:4095:1,0
1200-4095:-4095:1,0
12014095:-4095:-1,0
1202-4095:4095:-1,0
1203123:2:61,1
b3abae2a 12049:5:1,4
12059:4:2,1
6854fd01 1206# inf handling and general remainder
12075:8:0,5
12080:8:0,0
120911:2:5,1
121011:-2:-5,-1
1211-11:2:-5,1
1212# see table in documentation in MBI
12130:inf:0,0
12140:-inf:0,0
12155:inf:0,5
12165:-inf:0,5
1217-5:inf:0,-5
1218-5:-inf:0,-5
1219inf:5:inf,0
1220-inf:5:-inf,0
1221inf:-5:-inf,0
1222-inf:-5:inf,0
12235:5:1,0
1224-5:-5:1,0
b3abae2a 1225inf:inf:NaN,NaN
1226-inf:-inf:NaN,NaN
1227-inf:inf:NaN,NaN
1228inf:-inf:NaN,NaN
6854fd01 12298:0:inf,8
1230inf:0:inf,inf
1231# exceptions to reminder rule
1232-8:0:-inf,-8
1233-inf:0:-inf,-inf
12340:0:NaN,NaN
1235&bdiv
1236abc:abc:NaN
61f5c3f5 1237abc:1:NaN
12381:abc:NaN
12390:0:NaN
6854fd01 1240# inf handling (see table in doc)
12410:inf:0
12420:-inf:0
12435:inf:0
12445:-inf:0
1245-5:inf:0
1246-5:-inf:0
1247inf:5:inf
1248-inf:5:-inf
1249inf:-5:-inf
1250-inf:-5:inf
12515:5:1
1252-5:-5:1
b3abae2a 1253inf:inf:NaN
1254-inf:-inf:NaN
1255-inf:inf:NaN
1256inf:-inf:NaN
6854fd01 12578:0:inf
1258inf:0:inf
1259-8:0:-inf
1260-inf:0:-inf
12610:0:NaN
126211:2:5
1263-11:-2:5
1264-11:2:-5
126511:-2:-5
61f5c3f5 12660:1:0
12670:-1:0
12681:1:1
1269-1:-1:1
12701:-1:-1
1271-1:1:-1
12721:2:0
12732:1:2
12741:26:0
12751000000000:9:111111111
12762000000000:9:222222222
12773000000000:9:333333333
12784000000000:9:444444444
12795000000000:9:555555555
12806000000000:9:666666666
12817000000000:9:777777777
12828000000000:9:888888888
12839000000000:9:1000000000
128435500000:113:314159
128571000000:226:314159
1286106500000:339:314159
12871000000000:3:333333333
1288+10:+5:2
1289+100:+4:25
1290+1000:+8:125
1291+10000:+16:625
1292999999999999:9:111111111111
1293999999999999:99:10101010101
1294999999999999:999:1001001001
1295999999999999:9999:100010001
1296999999999999999:99999:10000100001
1297+1111088889:99999:11111
6854fd01 1298-5:-3:1
1299-5:3:-1
13004:3:1
13014:-3:-1
13021:3:0
13031:-3:0
1304-2:-3:0
1305-2:3:0
13068:3:2
1307-8:3:-2
130814:-3:-4
1309-14:3:-4
1310-14:-3:4
131114:3:4
1312# bug in Calc with '99999' vs $BASE-1
131310000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1314&bmod
1315# inf handling, see table in doc
13160:inf:0
13170:-inf:0
13185:inf:5
13195:-inf:5
1320-5:inf:-5
1321-5:-inf:-5
1322inf:5:0
1323-inf:5:0
1324inf:-5:0
1325-inf:-5:0
13265:5:0
1327-5:-5:0
b3abae2a 1328inf:inf:NaN
1329-inf:-inf:NaN
1330-inf:inf:NaN
1331inf:-inf:NaN
6854fd01 13328:0:8
1333inf:0:inf
1334# exceptions to reminder rule
1335-inf:0:-inf
1336-8:0:-8
13370:0:NaN
1338abc:abc:NaN
61f5c3f5 1339abc:1:abc:NaN
13401:abc:NaN
13410:0:NaN
13420:1:0
13431:0:1
13440:-1:0
1345-1:0:-1
13461:1:0
1347-1:-1:0
13481:-1:0
1349-1:1:0
13501:2:1
13512:1:0
13521000000000:9:1
13532000000000:9:2
13543000000000:9:3
13554000000000:9:4
13565000000000:9:5
13576000000000:9:6
13587000000000:9:7
13598000000000:9:8
13609000000000:9:0
136135500000:113:33
136271000000:226:66
1363106500000:339:99
13641000000000:3:1
136510:5:0
1366100:4:0
13671000:8:0
136810000:16:0
1369999999999999:9:0
1370999999999999:99:0
1371999999999999:999:0
1372999999999999:9999:0
1373999999999999999:99999:0
1374-9:+5:1
6854fd01 1375+9:-5:-1
1376-9:-5:-4
1377-5:3:1
1378-2:3:1
13794:3:1
13801:3:1
1381-5:-3:-2
1382-2:-3:-2
13834:-3:-2
13841:-3:-2
13854095:4095:0
027dc388 1386100041000510123:3:0
1387152403346:12345:4321
b3abae2a 13889:5:4
28df3e88 1389# test shortcuts in Calc
1390# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
13911234:9:1
1392123456:9:3
139312345678:9:0
13941234567891:9:1
1395123456789123:9:6
139612345678912345:9:6
13971234567891234567:9:1
1398123456789123456789:9:0
13991234:10:4
1400123456:10:6
140112345678:10:8
14021234567891:10:1
1403123456789123:10:3
140412345678912345:10:5
14051234567891234567:10:7
1406123456789123456789:10:9
14071234:113:104
1408123456:113:60
140912345678:113:89
14101234567891:113:64
1411123456789123:113:95
141212345678912345:113:53
14131234567891234567:113:56
1414123456789123456789:113:39
6854fd01 1415&bgcd
1416abc:abc:NaN
1417abc:+0:NaN
1418+0:abc:NaN
61f5c3f5 1419+0:+0:0
1420+0:+1:1
1421+1:+0:1
1422+1:+1:1
1423+2:+3:1
1424+3:+2:1
1425-3:+2:1
1426100:625:25
14274096:81:1
14281034:804:2
142927:90:56:1
143027:90:54:9
6854fd01 1431&blcm
1432abc:abc:NaN
1433abc:+0:NaN
1434+0:abc:NaN
1435+0:+0:NaN
61f5c3f5 1436+1:+0:0
1437+0:+1:0
1438+27:+90:270
1439+1034:+804:415668
6854fd01 1440&band
1441abc:abc:NaN
1442abc:0:NaN
14430:abc:NaN
14441:2:0
14453:2:2
61f5c3f5 1446+8:+2:0
1447+281474976710656:0:0
1448+281474976710656:1:0
1449+281474976710656:+281474976710656:281474976710656
6854fd01 1450-2:-3:-4
1451-1:-1:-1
1452-6:-6:-6
1453-7:-4:-8
1454-7:4:0
1455-4:7:4
394e6ffb 1456# equal arguments are treated special, so also do some test with unequal ones
14570xFFFF:0xFFFF:0x0xFFFF
14580xFFFFFF:0xFFFFFF:0x0xFFFFFF
14590xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
14600xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14610xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14620xF0F0:0xF0F0:0x0xF0F0
14630x0F0F:0x0F0F:0x0x0F0F
14640xF0F0F0:0xF0F0F0:0x0xF0F0F0
14650x0F0F0F:0x0F0F0F:0x0x0F0F0F
14660xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
14670x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
14680xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
14690x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
14700xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
14710x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
14720x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1473&bior
1474abc:abc:NaN
1475abc:0:NaN
14760:abc:NaN
14771:2:3
61f5c3f5 1478+8:+2:10
1479+281474976710656:0:281474976710656
1480+281474976710656:1:281474976710657
1481+281474976710656:281474976710656:281474976710656
6854fd01 1482-2:-3:-1
1483-1:-1:-1
1484-6:-6:-6
1485-7:4:-3
1486-4:7:-1
394e6ffb 1487# equal arguments are treated special, so also do some test with unequal ones
14880xFFFF:0xFFFF:0x0xFFFF
14890xFFFFFF:0xFFFFFF:0x0xFFFFFF
14900xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
14910xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14920xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14930:0xFFFF:0x0xFFFF
14940:0xFFFFFF:0x0xFFFFFF
14950:0xFFFFFFFF:0x0xFFFFFFFF
14960:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14970:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14980xFFFF:0:0x0xFFFF
14990xFFFFFF:0:0x0xFFFFFF
15000xFFFFFFFF:0:0x0xFFFFFFFF
15010xFFFFFFFFFF:0:0x0xFFFFFFFFFF
15020xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
15030xF0F0:0xF0F0:0x0xF0F0
15040x0F0F:0x0F0F:0x0x0F0F
15050xF0F0:0x0F0F:0x0xFFFF
15060xF0F0F0:0xF0F0F0:0x0xF0F0F0
15070x0F0F0F:0x0F0F0F:0x0x0F0F0F
15080x0F0F0F:0xF0F0F0:0x0xFFFFFF
15090xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
15100x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
15110x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
15120xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
15130x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
15140x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
15150xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
15160x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
15170x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
15180x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1519&bxor
1520abc:abc:NaN
1521abc:0:NaN
15220:abc:NaN
15231:2:3
61f5c3f5 1524+8:+2:10
1525+281474976710656:0:281474976710656
1526+281474976710656:1:281474976710657
1527+281474976710656:281474976710656:0
6854fd01 1528-2:-3:3
1529-1:-1:0
1530-6:-6:0
1531-7:4:-3
1532-4:7:-5
15334:-7:-3
1534-4:-7:5
394e6ffb 1535# equal arguments are treated special, so also do some test with unequal ones
15360xFFFF:0xFFFF:0
15370xFFFFFF:0xFFFFFF:0
15380xFFFFFFFF:0xFFFFFFFF:0
15390xFFFFFFFFFF:0xFFFFFFFFFF:0
15400xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
15410:0xFFFF:0x0xFFFF
15420:0xFFFFFF:0x0xFFFFFF
15430:0xFFFFFFFF:0x0xFFFFFFFF
15440:0xFFFFFFFFFF:0x0xFFFFFFFFFF
15450:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
15460xFFFF:0:0x0xFFFF
15470xFFFFFF:0:0x0xFFFFFF
15480xFFFFFFFF:0:0x0xFFFFFFFF
15490xFFFFFFFFFF:0:0x0xFFFFFFFFFF
15500xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
15510xF0F0:0xF0F0:0
15520x0F0F:0x0F0F:0
15530xF0F0:0x0F0F:0x0xFFFF
15540xF0F0F0:0xF0F0F0:0
15550x0F0F0F:0x0F0F0F:0
15560x0F0F0F:0xF0F0F0:0x0xFFFFFF
15570xF0F0F0F0:0xF0F0F0F0:0
15580x0F0F0F0F:0x0F0F0F0F:0
15590x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
15600xF0F0F0F0F0:0xF0F0F0F0F0:0
15610x0F0F0F0F0F:0x0F0F0F0F0F:0
15620x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
15630xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
15640x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
15650x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1566&bnot
1567abc:NaN
1568+0:-1
1569+8:-9
1570+281474976710656:-281474976710657
1571-1:0
1572-2:1
1573-12:11
1574&digit
15750:0:0
157612:0:2
157712:1:1
1578123:0:3
1579123:1:2
1580123:2:1
1581123:-1:1
1582123:-2:2
1583123:-3:3
1584123456:0:6
1585123456:1:5
1586123456:2:4
1587123456:3:3
1588123456:4:2
1589123456:5:1
1590123456:-1:1
1591123456:-2:2
1592123456:-3:3
1593100000:-3:0
1594100000:0:0
1595100000:1:0
1596&mantissa
1597abc:NaN
15981e4:1
15992e0:2
1600123:123
1601-1:-1
1602-2:-2
1603+inf:inf
1604-inf:-inf
1605&exponent
1606abc:NaN
16071e4:4
16082e0:0
1609123:0
1610-1:0
1611-2:0
16120:1
1613+inf:inf
1614-inf:inf
1615&parts
1616abc:NaN,NaN
16171e4:1,4
16182e0:2,0
1619123:123,0
1620-1:-1,0
1621-2:-2,0
16220:0,1
1623+inf:inf,inf
1624-inf:-inf,inf
b3abae2a 1625&bfac
1626-1:NaN
1627NaNfac:NaN
1628+inf:NaN
1629-inf:NaN
16300:1
16311:1
16322:2
16333:6
16344:24
16355:120
16366:720
163710:3628800
163811:39916800
163912:479001600
6854fd01 1640&bpow
1641abc:12:NaN
164212:abc:NaN
16430:0:1
16440:1:0
16450:2:0
16460:-1:NaN
16470:-2:NaN
16481:0:1
16491:1:1
16501:2:1
16511:3:1
16521:-1:1
16531:-2:1
16541:-3:1
16552:0:1
16562:1:2
16572:2:4
16582:3:8
16593:3:27
16602:-1:NaN
1661-2:-1:NaN
16622:-2:NaN
1663-2:-2:NaN
1664+inf:1234500012:inf
1665-inf:1234500012:-inf
1666+inf:-12345000123:inf
1667-inf:-12345000123:-inf
1668# 1 ** -x => 1 / (1 ** x)
1669-1:0:1
1670-2:0:1
1671-1:1:-1
1672-1:2:1
1673-1:3:-1
1674-1:4:1
1675-1:5:-1
1676-1:-1:-1
1677-1:-2:1
1678-1:-3:-1
1679-1:-4:1
168010:2:100
168110:3:1000
168210:4:10000
168310:5:100000
168410:6:1000000
168510:7:10000000
168610:8:100000000
168710:9:1000000000
168810:20:100000000000000000000
1689123456:2:15241383936
1690&length
1691100:3
169210:2
16931:1
16940:1
169512345:5
169610000000000000000:17
1697-123:3
1698215960156869840440586892398248:30
1699&bsqrt
394e6ffb 1700145:12
6854fd01 1701144:12
394e6ffb 1702143:11
6854fd01 170316:4
394e6ffb 1704170:13
1705169:13
1706168:12
6854fd01 17074:2
394e6ffb 17083:1
6854fd01 17092:1
394e6ffb 17109:3
6854fd01 171112:3
1712256:16
1713100000000:10000
17144000000000000:2000000
394e6ffb 1715152399026:12345
1716152399025:12345
1717152399024:12344
6854fd01 17181:1
17190:0
1720-2:NaN
394e6ffb 1721-123:NaN
6854fd01 1722Nan:NaN
394e6ffb 1723+inf:NaN
6854fd01 1724&bround
1725$round_mode('trunc')
17260:12:0
1727NaNbround:12:NaN
1728+inf:12:inf
1729-inf:12:-inf
17301234:0:1234
17311234:2:1200
1732123456:4:123400
1733123456:5:123450
1734123456:6:123456
61f5c3f5 1735+10123456789:5:10123000000
6854fd01 1736-10123456789:5:-10123000000
61f5c3f5 1737+10123456789:9:10123456700
6854fd01 1738-10123456789:9:-10123456700
61f5c3f5 1739+101234500:6:101234000
6854fd01 1740-101234500:6:-101234000
61f5c3f5 1741#+101234500:-4:101234000
6854fd01 1742#-101234500:-4:-101234000
1743$round_mode('zero')
61f5c3f5 1744+20123456789:5:20123000000
6854fd01 1745-20123456789:5:-20123000000
61f5c3f5 1746+20123456789:9:20123456800
6854fd01 1747-20123456789:9:-20123456800
61f5c3f5 1748+201234500:6:201234000
6854fd01 1749-201234500:6:-201234000
61f5c3f5 1750#+201234500:-4:201234000
6854fd01 1751#-201234500:-4:-201234000
1752+12345000:4:12340000
1753-12345000:4:-12340000
1754$round_mode('+inf')
61f5c3f5 1755+30123456789:5:30123000000
6854fd01 1756-30123456789:5:-30123000000
61f5c3f5 1757+30123456789:9:30123456800
6854fd01 1758-30123456789:9:-30123456800
61f5c3f5 1759+301234500:6:301235000
6854fd01 1760-301234500:6:-301234000
61f5c3f5 1761#+301234500:-4:301235000
6854fd01 1762#-301234500:-4:-301234000
1763+12345000:4:12350000
1764-12345000:4:-12340000
1765$round_mode('-inf')
61f5c3f5 1766+40123456789:5:40123000000
6854fd01 1767-40123456789:5:-40123000000
61f5c3f5 1768+40123456789:9:40123456800
6854fd01 1769-40123456789:9:-40123456800
61f5c3f5 1770+401234500:6:401234000
1771+401234500:6:401234000
6854fd01 1772#-401234500:-4:-401235000
1773#-401234500:-4:-401235000
1774+12345000:4:12340000
1775-12345000:4:-12350000
1776$round_mode('odd')
61f5c3f5 1777+50123456789:5:50123000000
6854fd01 1778-50123456789:5:-50123000000
61f5c3f5 1779+50123456789:9:50123456800
6854fd01 1780-50123456789:9:-50123456800
61f5c3f5 1781+501234500:6:501235000
6854fd01 1782-501234500:6:-501235000
61f5c3f5 1783#+501234500:-4:501235000
6854fd01 1784#-501234500:-4:-501235000
1785+12345000:4:12350000
1786-12345000:4:-12350000
1787$round_mode('even')
61f5c3f5 1788+60123456789:5:60123000000
6854fd01 1789-60123456789:5:-60123000000
61f5c3f5 1790+60123456789:9:60123456800
6854fd01 1791-60123456789:9:-60123456800
61f5c3f5 1792+601234500:6:601234000
6854fd01 1793-601234500:6:-601234000
61f5c3f5 1794#+601234500:-4:601234000
6854fd01 1795#-601234500:-4:-601234000
1796#-601234500:-9:0
1797#-501234500:-9:0
1798#-601234500:-8:0
1799#-501234500:-8:0
1800+1234567:7:1234567
1801+1234567:6:1234570
1802+12345000:4:12340000
1803-12345000:4:-12340000
1804&is_zero
18050:1
1806NaNzero:0
1807+inf:0
1808-inf:0
1809123:0
1810-1:0
18111:0
1812&is_one
18130:0
1814NaNone:0
1815+inf:0
1816-inf:0
18171:1
18182:0
1819-1:0
1820-2:0
1821# floor and ceil tests are pretty pointless in integer space...but play safe
1822&bfloor
18230:0
1824NaNfloor:NaN
1825+inf:inf
1826-inf:-inf
1827-1:-1
1828-2:-2
18292:2
18303:3
1831abc:NaN
1832&bceil
1833NaNceil:NaN
1834+inf:inf
1835-inf:-inf
18360:0
1837-1:-1
1838-2:-2
18392:2
18403:3
1841abc:NaN
1842&as_hex
1843128:0x80
1844-128:-0x80
18450:0x0
1846-0:0x0
18471:0x1
18480x123456789123456789:0x123456789123456789
1849+inf:inf
1850-inf:-inf
1851NaNas_hex:NaN
1852&as_bin
1853128:0b10000000
1854-128:-0b10000000
18550:0b0
1856-0:0b0
18571:0b1
18580b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1859+inf:inf
1860-inf:-inf
1861NaNas_bin:NaN