Upgrade to Encode 0.97, from Dan Kogai.
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigintpm.inc
CommitLineData
6854fd01 1#include this file into another for subclass testing
2
3my $version = ${"$class\::VERSION"};
4
5##############################################################################
6# for testing inheritance of _swap
7
8package Math::Foo;
9
61f5c3f5 10use Math::BigInt lib => $main::CL;
6854fd01 11use vars qw/@ISA/;
12@ISA = (qw/Math::BigInt/);
13
14use overload
15# customized overload for sub, since original does not use swap there
16'-' => sub { my @a = ref($_[0])->_swap(@_);
17 $a[0]->bsub($a[1])};
18
19sub _swap
20 {
21 # a fake _swap, which reverses the params
22 my $self = shift; # for override in subclass
23 if ($_[2])
24 {
25 my $c = ref ($_[0] ) || 'Math::Foo';
26 return ( $_[0]->copy(), $_[1] );
27 }
28 else
29 {
30 return ( Math::Foo->new($_[1]), $_[0] );
31 }
32 }
33
34##############################################################################
35package main;
36
b3abae2a 37my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
6854fd01 38
b3abae2a 39my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
6854fd01 40
41while (<DATA>)
42 {
43 chop;
44 next if /^#/; # skip comments
45 if (s/^&//)
46 {
61f5c3f5 47 $f = $_; next;
6854fd01 48 }
49 elsif (/^\$/)
50 {
61f5c3f5 51 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
6854fd01 52 }
61f5c3f5 53
54 @args = split(/:/,$_,99); $ans = pop(@args);
b3abae2a 55 $expected_class = $class;
56 if ($ans =~ /(.*?)=(.*)/)
57 {
58 $expected_class = $2; $ans = $1;
59 }
61f5c3f5 60 $try = "\$x = $class->new(\"$args[0]\");";
61 if ($f eq "bnorm")
6854fd01 62 {
61f5c3f5 63 $try = "\$x = $class->bnorm(\"$args[0]\");";
64 # some is_xxx tests
b3abae2a 65 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
61f5c3f5 66 $try .= "\$x->$f();";
67 } elsif ($f eq "as_hex") {
68 $try .= '$x->as_hex();';
69 } elsif ($f eq "as_bin") {
70 $try .= '$x->as_bin();';
71 } elsif ($f eq "is_inf") {
72 $try .= "\$x->is_inf('$args[1]');";
73 } elsif ($f eq "binf") {
74 $try .= "\$x->binf('$args[1]');";
75 } elsif ($f eq "bone") {
76 $try .= "\$x->bone('$args[1]');";
77 # some unary ops
b3abae2a 78 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
61f5c3f5 79 $try .= "\$x->$f();";
80 } elsif ($f eq "length") {
81 $try .= '$x->length();';
82 } elsif ($f eq "exponent"){
83 # ->bstr() to see if an object is returned
84 $try .= '$x = $x->exponent()->bstr();';
85 } elsif ($f eq "mantissa"){
86 # ->bstr() to see if an object is returned
87 $try .= '$x = $x->mantissa()->bstr();';
88 } elsif ($f eq "parts"){
89 $try .= '($m,$e) = $x->parts();';
90 # ->bstr() to see if an object is returned
91 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
92 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
93 $try .= '"$m,$e";';
94 } else {
95 $try .= "\$y = $class->new('$args[1]');";
96 if ($f eq "bcmp")
97 {
98 $try .= '$x <=> $y;';
99 } elsif ($f eq "bround") {
6854fd01 100 $try .= "$round_mode; \$x->bround(\$y);";
61f5c3f5 101 } elsif ($f eq "bacmp"){
102 $try .= '$x->bacmp($y);';
103 } elsif ($f eq "badd"){
104 $try .= '$x + $y;';
105 } elsif ($f eq "bsub"){
106 $try .= '$x - $y;';
107 } elsif ($f eq "bmul"){
108 $try .= '$x * $y;';
109 } elsif ($f eq "bdiv"){
110 $try .= '$x / $y;';
111 } elsif ($f eq "bdiv-list"){
112 $try .= 'join (",",$x->bdiv($y));';
027dc388 113 # overload via x=
61f5c3f5 114 } elsif ($f =~ /^.=$/){
115 $try .= "\$x $f \$y;";
027dc388 116 # overload via x
61f5c3f5 117 } elsif ($f =~ /^.$/){
118 $try .= "\$x $f \$y;";
119 } elsif ($f eq "bmod"){
120 $try .= '$x % $y;';
121 } elsif ($f eq "bgcd")
6854fd01 122 {
123 if (defined $args[2])
124 {
61f5c3f5 125 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 126 }
127 $try .= "$class\::bgcd(\$x, \$y";
128 $try .= ", \$z" if (defined $args[2]);
129 $try .= " );";
130 }
131 elsif ($f eq "blcm")
132 {
133 if (defined $args[2])
134 {
61f5c3f5 135 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 136 }
137 $try .= "$class\::blcm(\$x, \$y";
138 $try .= ", \$z" if (defined $args[2]);
139 $try .= " );";
140 }elsif ($f eq "blsft"){
141 if (defined $args[2])
142 {
143 $try .= "\$x->blsft(\$y,$args[2]);";
144 }
145 else
146 {
147 $try .= "\$x << \$y;";
148 }
149 }elsif ($f eq "brsft"){
150 if (defined $args[2])
151 {
152 $try .= "\$x->brsft(\$y,$args[2]);";
153 }
154 else
155 {
156 $try .= "\$x >> \$y;";
157 }
158 }elsif ($f eq "band"){
159 $try .= "\$x & \$y;";
160 }elsif ($f eq "bior"){
161 $try .= "\$x | \$y;";
162 }elsif ($f eq "bxor"){
163 $try .= "\$x ^ \$y;";
164 }elsif ($f eq "bpow"){
165 $try .= "\$x ** \$y;";
166 }elsif ($f eq "digit"){
61f5c3f5 167 $try = "\$x = $class->new('$args[0]'); \$x->digit($args[1]);";
6854fd01 168 } else { warn "Unknown op '$f'"; }
61f5c3f5 169 } # end else all other ops
170
171 $ans1 = eval $try;
172 # convert hex/binary targets to decimal
173 if ($ans =~ /^(0x0x|0b0b)/)
174 {
175 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 176 }
61f5c3f5 177 if ($ans eq "")
178 {
179 ok_undef ($ans1);
180 }
181 else
182 {
183 # print "try: $try ans: $ans1 $ans\n";
184 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
b3abae2a 185 ok (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 186 }
61f5c3f5 187 # check internal state of number objects
188 is_valid($ans1,$f) if ref $ans1;
6854fd01 189 } # endwhile data tests
190close DATA;
191
192# test some more
193@a = ();
194for (my $i = 1; $i < 10; $i++)
195 {
196 push @a, $i;
197 }
198ok "@a", "1 2 3 4 5 6 7 8 9";
199
200# test whether self-multiplication works correctly (result is 2**64)
201$try = "\$x = $class->new('4294967296');";
202$try .= '$a = $x->bmul($x);';
203$ans1 = eval $try;
204print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
205# test self-pow
206$try = "\$x = $class->new(10);";
207$try .= '$a = $x->bpow($x);';
208$ans1 = eval $try;
209print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
210
211# test whether op destroys args or not (should better not)
212
213$x = $class->new(3);
214$y = $class->new(4);
215$z = $x & $y;
216ok ($x,3);
217ok ($y,4);
218ok ($z,0);
219$z = $x | $y;
220ok ($x,3);
221ok ($y,4);
222ok ($z,7);
223$x = $class->new(1);
224$y = $class->new(2);
225$z = $x | $y;
226ok ($x,1);
227ok ($y,2);
228ok ($z,3);
229
230$x = $class->new(5);
231$y = $class->new(4);
232$z = $x ^ $y;
233ok ($x,5);
234ok ($y,4);
235ok ($z,1);
236
237$x = $class->new(-5); $y = -$x;
238ok ($x, -5);
239
240$x = $class->new(-5); $y = abs($x);
241ok ($x, -5);
242
243# check whether overloading cmp works
244$try = "\$x = $class->new(0);";
245$try .= "\$y = 10;";
246$try .= "'false' if \$x ne \$y;";
247$ans = eval $try;
248print "# For '$try'\n" if (!ok "$ans" , "false" );
249
250# we cant test for working cmpt with other objects here, we would need a dummy
251# object with stringify overload for this. see Math::String tests as example
252
253###############################################################################
6854fd01 254# check reversed order of arguments
027dc388 255
6854fd01 256$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
257$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
258print "# For '$try'\n" if (!ok "$ans" , "ok" );
259
260$try = "\$x = $class->new(10); \$x = 2 * \$x;";
261$try .= "'ok' if \$x == 20;"; $ans = eval $try;
262print "# For '$try'\n" if (!ok "$ans" , "ok" );
263
264$try = "\$x = $class->new(10); \$x = 2 + \$x;";
265$try .= "'ok' if \$x == 12;"; $ans = eval $try;
266print "# For '$try'\n" if (!ok "$ans" , "ok" );
267
268$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
269$try .= "'ok' if \$x == -8;"; $ans = eval $try;
270print "# For '$try'\n" if (!ok "$ans" , "ok" );
271
272$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
273$try .= "'ok' if \$x == 2;"; $ans = eval $try;
274print "# For '$try'\n" if (!ok "$ans" , "ok" );
275
027dc388 276$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
277$try .= "'ok' if \$x == 2;"; $ans = eval $try;
278print "# For '$try'\n" if (!ok "$ans" , "ok" );
279
280$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
281$try .= "'ok' if \$x == 4;"; $ans = eval $try;
282print "# For '$try'\n" if (!ok "$ans" , "ok" );
283
284$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
285$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
286print "# For '$try'\n" if (!ok "$ans" , "ok" );
287
288$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
289$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
290print "# For '$try'\n" if (!ok "$ans" , "ok" );
291
6854fd01 292###############################################################################
293# check badd(4,5) form
294
295$try = "\$x = $class\->badd(4,5);";
296$try .= "'ok' if \$x == 9;";
297$ans = eval $try;
298print "# For '$try'\n" if (!ok "$ans" , "ok" );
299
300###############################################################################
301# check undefs: NOT DONE YET
302
303###############################################################################
304# bool
305
306$x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
307$x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
308
309###############################################################################
310# objectify()
311
312@args = Math::BigInt::objectify(2,4,5);
313ok (scalar @args,3); # $class, 4, 5
314ok ($args[0],$class);
315ok ($args[1],4);
316ok ($args[2],5);
317
318@args = Math::BigInt::objectify(0,4,5);
319ok (scalar @args,3); # $class, 4, 5
320ok ($args[0],$class);
321ok ($args[1],4);
322ok ($args[2],5);
323
324@args = Math::BigInt::objectify(2,4,5);
325ok (scalar @args,3); # $class, 4, 5
326ok ($args[0],$class);
327ok ($args[1],4);
328ok ($args[2],5);
329
330@args = Math::BigInt::objectify(2,4,5,6,7);
331ok (scalar @args,5); # $class, 4, 5, 6, 7
332ok ($args[0],$class);
333ok ($args[1],4); ok (ref($args[1]),$args[0]);
334ok ($args[2],5); ok (ref($args[2]),$args[0]);
335ok ($args[3],6); ok (ref($args[3]),'');
336ok ($args[4],7); ok (ref($args[4]),'');
337
338@args = Math::BigInt::objectify(2,$class,4,5,6,7);
339ok (scalar @args,5); # $class, 4, 5, 6, 7
340ok ($args[0],$class);
341ok ($args[1],4); ok (ref($args[1]),$args[0]);
342ok ($args[2],5); ok (ref($args[2]),$args[0]);
343ok ($args[3],6); ok (ref($args[3]),'');
344ok ($args[4],7); ok (ref($args[4]),'');
345
346###############################################################################
347# test for floating-point input (other tests in bnorm() below)
348
349$z = 1050000000000000; # may be int on systems with 64bit?
350$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
351$z = 1e+129; # definitely a float (may fail on UTS)
352# don't compare to $z, since some Perl versions stringify $z into something
353# like '1.e+129' or something equally ugly
354$x = $class->new($z); ok ($x->bsstr(),'1e+129');
355
356###############################################################################
357# prime number tests, also test for **= and length()
358# found on: http://www.utm.edu/research/primes/notes/by_year.html
359
360# ((2^148)-1)/17
361$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
362ok ($x,"20988936657440586486151264256610222593863921");
363ok ($x->length(),length "20988936657440586486151264256610222593863921");
364
365# MM7 = 2^127-1
366$x = $class->new(2); $x **= 127; $x--;
367ok ($x,"170141183460469231731687303715884105727");
368
369$x = $class->new('215960156869840440586892398248');
370($x,$y) = $x->length();
371ok ($x,30); ok ($y,0);
372
373$x = $class->new('1_000_000_000_000');
374($x,$y) = $x->length();
375ok ($x,13); ok ($y,0);
376
377# I am afraid the following is not yet possible due to slowness
378# Also, testing for 2 meg output is a bit hard ;)
379#$x = $class->new(2); $x **= 6972593; $x--;
380
381# 593573509*2^332162+1 has exactly 1,000,000 digits
382# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
383#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
384#ok ($x->length(),1_000_000);
385
386###############################################################################
387# inheritance and overriding of _swap
388
389$x = Math::Foo->new(5);
390$x = $x - 8; # 8 - 5 instead of 5-8
391ok ($x,3);
392ok (ref($x),'Math::Foo');
393
394$x = Math::Foo->new(5);
395$x = 8 - $x; # 5 - 8 instead of 8 - 5
396ok ($x,-3);
397ok (ref($x),'Math::Foo');
398
399###############################################################################
400# Test whether +inf eq inf
401# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
402# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
403# like 1e100000 crash on some platforms. So simple test for the string 'inf'
404$x = $class->new('+inf'); ok ($x,'inf');
405
406###############################################################################
407###############################################################################
394e6ffb 408# the followin tests only make sense with Math::BigInt::Calc or BareCalc
6854fd01 409
394e6ffb 410exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
6854fd01 411
412###############################################################################
413# check proper length of internal arrays
414
394e6ffb 415my $bl = $CL->_base_len();
6854fd01 416my $BASE = '9' x $bl;
417my $MAX = $BASE;
418$BASE++;
419
420$x = $class->new($MAX); is_valid($x); # f.i. 9999
421$x += 1; ok ($x,$BASE); is_valid($x); # 10000
422$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
423
424###############################################################################
425# check numify
426
427$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
428$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
61f5c3f5 429
430# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
431$x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
6854fd01 432$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
433$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
434ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
435
436###############################################################################
437# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
438
394e6ffb 439$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
440if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
441
442$x = $class->new($BASE+3); $x++;
443if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 444
394e6ffb 445# test for +0 instead of int():
446$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 447
448###############################################################################
449# bug in sub where number with at least 6 trailing zeros after any op failed
450
394e6ffb 451$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 452ok ($z, 100000);
453ok ($x, 23456);
454
455###############################################################################
456# bug in shortcut in mul()
457
61f5c3f5 458# construct a number with a zero-hole of BASE_LEN_SMALL
459{
460 my @bl = $CL->_base_len(); my $bl = $bl[4];
461
462 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
463 $y = '1' x (2*$bl);
464 $x = $class->new($x)->bmul($y);
465 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
466 $y = ''; my $d = '';
467 for (my $i = 1; $i <= $bl; $i++)
468 {
469 $y .= $i; $d = $i.$d;
470 }
471 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
472 ok ($x,$y);
473
6854fd01 474
475###############################################################################
394e6ffb 476# see if mul shortcut for small numbers works
477
478$x = '9' x $bl;
479$x = $class->new($x);
480# 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
481ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
482
61f5c3f5 483 }
484
394e6ffb 485###############################################################################
6854fd01 486# bug with rest "-0" in div, causing further div()s to fail
487
394e6ffb 488$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 489
61f5c3f5 490ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 491
79c55733 492###############################################################################
61f5c3f5 493# all tests done
6854fd01 494
4951;
496
497###############################################################################
61f5c3f5 498###############################################################################
6854fd01 499# Perl 5.005 does not like ok ($x,undef)
500
501sub ok_undef
502 {
503 my $x = shift;
504
505 ok (1,1) and return if !defined $x;
506 ok ($x,'undef');
507 }
508
509###############################################################################
510# sub to check validity of a BigInt internally, to ensure that no op leaves a
511# number object in an invalid state (f.i. "-0")
512
513sub is_valid
514 {
515 my ($x,$f) = @_;
516
517 my $e = 0; # error?
518 # ok as reference?
519 $e = 'Not a reference to Math::BigInt' if !ref($x);
520
521 # has ok sign?
522 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
523 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
524
525 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
526 $e = $CALC->_check($x->{value}) if $e eq '0';
527
528 # test done, see if error did crop up
529 ok (1,1), return if ($e eq '0');
530
027dc388 531 ok (1,$e." after op '$f'");
6854fd01 532 }
533
534__DATA__
027dc388 535&.=
5361234:-345:1234-345
537&+=
5381:2:3
539-1:-2:-3
540&-=
5411:2:-1
542-1:-2:1
543&*=
5442:3:6
545-1:5:-5
546&%=
547100:3:1
5488:9:8
549&/=
550100:3:33
551-8:2:-4
552&|=
5532:1:3
554&&=
5555:7:5
556&^=
5575:7:2
6854fd01 558&is_negative
5590:0
560-1:1
5611:0
562+inf:0
563-inf:1
564NaNneg:0
565&is_positive
5660:1
567-1:0
5681:1
569+inf:1
570-inf:0
571NaNneg:0
b3abae2a 572&is_int
573-inf:0
574+inf:0
575NaNis_int:0
5761:1
5770:1
578123e12:1
6854fd01 579&is_odd
580abc:0
5810:0
5821:1
5833:1
584-1:1
585-3:1
58610000001:1
58710000002:0
5882:0
b3abae2a 589120:0
590121:1
6854fd01 591&is_even
592abc:0
5930:1
5941:0
5953:0
596-1:0
597-3:0
59810000001:0
59910000002:1
6002:1
b3abae2a 601120:1
602121:0
6854fd01 603&bacmp
604+0:-0:0
605+0:+1:-1
606-1:+1:0
607+1:-1:0
608-1:+2:-1
609+2:-1:1
610-123456789:+987654321:-1
611+123456789:-987654321:-1
612+987654321:+123456789:1
613-987654321:+123456789:1
614-123:+4567889:-1
615# NaNs
616acmpNaN:123:
617123:acmpNaN:
618acmpNaN:acmpNaN:
619# infinity
620+inf:+inf:0
621-inf:-inf:0
622+inf:-inf:0
623-inf:+inf:0
624+inf:123:1
625-inf:123:1
626+inf:-123:1
627-inf:-123:1
628# return undef
629+inf:NaN:
630NaN:inf:
631-inf:NaN:
632NaN:-inf:
633&bnorm
634123:123
635# binary input
6360babc:NaN
6370b123:NaN
6380b0:0
639-0b0:0
640-0b1:-1
6410b0001:1
6420b001:1
6430b011:3
6440b101:5
61f5c3f5 6450b1001:9
6460b10001:17
6470b100001:33
6480b1000001:65
6490b10000001:129
6500b100000001:257
6510b1000000001:513
6520b10000000001:1025
6530b100000000001:2049
6540b1000000000001:4097
6550b10000000000001:8193
6560b100000000000001:16385
6570b1000000000000001:32769
6580b10000000000000001:65537
6590b100000000000000001:131073
6600b1000000000000000001:262145
6610b10000000000000000001:524289
6620b100000000000000000001:1048577
6630b1000000000000000000001:2097153
6640b10000000000000000000001:4194305
6650b100000000000000000000001:8388609
6660b1000000000000000000000001:16777217
6670b10000000000000000000000001:33554433
6680b100000000000000000000000001:67108865
6690b1000000000000000000000000001:134217729
6700b10000000000000000000000000001:268435457
6710b100000000000000000000000000001:536870913
6720b1000000000000000000000000000001:1073741825
6730b10000000000000000000000000000001:2147483649
6740b100000000000000000000000000000001:4294967297
6750b1000000000000000000000000000000001:8589934593
6760b10000000000000000000000000000000001:17179869185
6854fd01 6770b_101:NaN
6780b1_0_1:5
394e6ffb 6790b0_0_0_1:1
6854fd01 680# hex input
681-0x0:0
6820xabcdefgh:NaN
6830x1234:4660
6840xabcdef:11259375
685-0xABCDEF:-11259375
686-0x1234:-4660
6870x12345678:305419896
6880x1_2_3_4_56_78:305419896
394e6ffb 6890xa_b_c_d_e_f:11259375
6854fd01 6900x_123:NaN
61f5c3f5 6910x9:9
6920x11:17
6930x21:33
6940x41:65
6950x81:129
6960x101:257
6970x201:513
6980x401:1025
6990x801:2049
7000x1001:4097
7010x2001:8193
7020x4001:16385
7030x8001:32769
7040x10001:65537
7050x20001:131073
7060x40001:262145
7070x80001:524289
7080x100001:1048577
7090x200001:2097153
7100x400001:4194305
7110x800001:8388609
7120x1000001:16777217
7130x2000001:33554433
7140x4000001:67108865
7150x8000001:134217729
7160x10000001:268435457
7170x20000001:536870913
7180x40000001:1073741825
7190x80000001:2147483649
7200x100000001:4294967297
7210x200000001:8589934593
7220x400000001:17179869185
7230x800000001:34359738369
6854fd01 724# inf input
725inf:inf
726+inf:inf
727-inf:-inf
7280inf:NaN
027dc388 729# abnormal input
6854fd01 730:NaN
731abc:NaN
732 1 a:NaN
7331bcd2:NaN
73411111b:NaN
735+1z:NaN
736-1z:NaN
027dc388 737# only one underscore between two digits
738_123:NaN
739_123_:NaN
740123_:NaN
7411__23:NaN
7421E1__2:NaN
7431_E12:NaN
7441E_12:NaN
7451_E_12:NaN
746+_1E12:NaN
747+0_1E2:100
748+0_0_1E2:100
749-0_0_1E2:-100
750-0_0_1E+0_0_2:-100
751E1:NaN
752E23:NaN
7531.23E1:NaN
7541.23E-1:NaN
755# bug with two E's in number beeing valid
7561e2e3:NaN
7571e2r:NaN
7581e2.0:NaN
61f5c3f5 759# leading zeros
760012:12
7610123:123
76201234:1234
763012345:12345
7640123456:123456
76501234567:1234567
766012345678:12345678
7670123456789:123456789
76801234567891:1234567891
769012345678912:12345678912
7700123456789123:123456789123
77101234567891234:1234567891234
027dc388 772# normal input
6854fd01 7730:0
774+0:0
775+00:0
776+000:0
777000000000000000000:0
778-0:0
779-0000:0
780+1:1
781+01:1
782+001:1
783+00000100000:100000
784123456789:123456789
785-1:-1
786-01:-1
787-001:-1
788-123456789:-123456789
789-00000100000:-100000
7901_2_3:123
6854fd01 79110000000000E-1_0:1
7921E2:100
7931E1:10
7941E0:1
6854fd01 7951.23E2:123
6854fd01 796100E-1:10
797# floating point input
027dc388 798# .2e2:20
7991.E3:1000
6854fd01 8001.01E2:101
8011010E-1:101
802-1010E0:-1010
803-1010E1:-10100
027dc388 8041234.00:1234
805# non-integer numbers
6854fd01 806-1010E-2:NaN
807-1.01E+1:NaN
808-1.01E-1:NaN
6854fd01 809&bnan
8101:NaN
8112:NaN
812abc:NaN
813&bone
61f5c3f5 8142:+:1
6854fd01 8152:-:-1
816boneNaN:-:-1
61f5c3f5 817boneNaN:+:1
8182:abc:1
8193::1
6854fd01 820&binf
8211:+:inf
8222:-:-inf
8233:abc:inf
027dc388 824&is_nan
825123:0
826abc:1
827NaN:1
828-123:0
6854fd01 829&is_inf
830+inf::1
831-inf::1
832abc::0
8331::0
834NaN::0
835-1::0
836+inf:-:0
837+inf:+:1
838-inf:-:1
839-inf:+:0
79c55733 840-inf:-inf:1
841-inf:+inf:0
842+inf:-inf:0
843+inf:+inf:1
6854fd01 844# it must be exactly /^[+-]inf$/
845+infinity::0
846-infinity::0
847&blsft
848abc:abc:NaN
61f5c3f5 849+2:+2:8
850+1:+32:4294967296
851+1:+48:281474976710656
6854fd01 852+8:-2:NaN
853# excercise base 10
854+12345:4:10:123450000
855-1234:0:10:-1234
61f5c3f5 856+1234:0:10:1234
6854fd01 857+2:2:10:200
858+12:2:10:1200
859+1234:-3:10:NaN
8601234567890123:12:10:1234567890123000000000000
b3abae2a 861-3:1:2:-6
862-5:1:2:-10
863-2:1:2:-4
864-102533203:1:2:-205066406
6854fd01 865&brsft
866abc:abc:NaN
61f5c3f5 867+8:+2:2
868+4294967296:+32:1
869+281474976710656:+48:1
6854fd01 870+2:-2:NaN
871# excercise base 10
872-1234:0:10:-1234
61f5c3f5 873+1234:0:10:1234
6854fd01 874+200:2:10:2
875+1234:3:10:1
876+1234:2:10:12
877+1234:-3:10:NaN
878310000:4:10:31
87912300000:5:10:123
8801230000000000:10:10:123
88109876123456789067890:12:10:9876123
8821234561234567890123:13:10:123456
b3abae2a 883820265627:1:2:410132813
884# test shifting negative numbers in base 2
885-15:1:2:-8
886-14:1:2:-7
887-13:1:2:-7
888-12:1:2:-6
889-11:1:2:-6
890-10:1:2:-5
891-9:1:2:-5
892-8:1:2:-4
893-7:1:2:-4
894-6:1:2:-3
895-5:1:2:-3
896-4:1:2:-2
897-3:1:2:-2
898-2:1:2:-1
899-1:1:2:-1
900-1640531254:2:2:-410132814
901-1640531254:1:2:-820265627
902-820265627:1:2:-410132814
903-205066405:1:2:-102533203
6854fd01 904&bsstr
9051e+34:1e+34
906123.456E3:123456e+0
907100:1e+2
908abc:NaN
909&bneg
910bnegNaN:NaN
911+inf:-inf
912-inf:inf
913abd:NaN
61f5c3f5 9140:0
9151:-1
916-1:1
6854fd01 917+123456789:-123456789
61f5c3f5 918-123456789:123456789
6854fd01 919&babs
920babsNaN:NaN
921+inf:inf
922-inf:inf
61f5c3f5 9230:0
9241:1
925-1:1
926+123456789:123456789
927-123456789:123456789
6854fd01 928&bcmp
929bcmpNaN:bcmpNaN:
61f5c3f5 930bcmpNaN:0:
9310:bcmpNaN:
9320:0:0
933-1:0:-1
9340:-1:1
9351:0:1
9360:1:-1
937-1:1:-1
9381:-1:1
6854fd01 939-1:-1:0
61f5c3f5 9401:1:0
941123:123:0
942123:12:1
94312:123:-1
6854fd01 944-123:-123:0
945-123:-12:-1
946-12:-123:1
61f5c3f5 947123:124:-1
948124:123:1
6854fd01 949-123:-124:1
950-124:-123:-1
61f5c3f5 951100:5:1
952-123456789:987654321:-1
6854fd01 953+123456789:-987654321:1
61f5c3f5 954-987654321:123456789:-1
6854fd01 955-inf:5432112345:-1
956+inf:5432112345:1
957-inf:-5432112345:-1
958+inf:-5432112345:1
959+inf:+inf:0
960-inf:-inf:0
961+inf:-inf:1
962-inf:+inf:-1
9635:inf:-1
9645:inf:-1
965-5:-inf:1
966-5:-inf:1
967# return undef
968+inf:NaN:
969NaN:inf:
970-inf:NaN:
971NaN:-inf:
972&binc
973abc:NaN
974+inf:inf
975-inf:-inf
61f5c3f5 976+0:1
977+1:2
978-1:0
6854fd01 979&bdec
980abc:NaN
981+inf:inf
982-inf:-inf
983+0:-1
61f5c3f5 984+1:0
6854fd01 985-1:-2
986&badd
987abc:abc:NaN
61f5c3f5 988abc:0:NaN
6854fd01 989+0:abc:NaN
b3abae2a 990+inf:-inf:NaN
991-inf:+inf:NaN
6854fd01 992+inf:+inf:inf
993-inf:-inf:-inf
994baddNaN:+inf:NaN
995baddNaN:+inf:NaN
996+inf:baddNaN:NaN
997-inf:baddNaN:NaN
61f5c3f5 9980:0:0
9991:0:1
10000:1:1
10011:1:2
1002-1:0:-1
10030:-1:-1
6854fd01 1004-1:-1:-2
61f5c3f5 1005-1:+1:0
1006+1:-1:0
1007+9:+1:10
1008+99:+1:100
1009+999:+1:1000
1010+9999:+1:10000
1011+99999:+1:100000
1012+999999:+1:1000000
1013+9999999:+1:10000000
1014+99999999:+1:100000000
1015+999999999:+1:1000000000
1016+9999999999:+1:10000000000
1017+99999999999:+1:100000000000
1018+10:-1:9
1019+100:-1:99
1020+1000:-1:999
1021+10000:-1:9999
1022+100000:-1:99999
1023+1000000:-1:999999
1024+10000000:-1:9999999
1025+100000000:-1:99999999
1026+1000000000:-1:999999999
1027+10000000000:-1:9999999999
1028+123456789:987654321:1111111110
1029-123456789:987654321:864197532
6854fd01 1030-123456789:-987654321:-1111111110
1031+123456789:-987654321:-864197532
1032&bsub
1033abc:abc:NaN
1034abc:+0:NaN
1035+0:abc:NaN
1036+inf:-inf:inf
1037-inf:+inf:-inf
b3abae2a 1038+inf:+inf:NaN
1039-inf:-inf:NaN
61f5c3f5 1040+0:+0:0
1041+1:+0:1
6854fd01 1042+0:+1:-1
61f5c3f5 1043+1:+1:0
6854fd01 1044-1:+0:-1
61f5c3f5 1045+0:-1:1
1046-1:-1:0
6854fd01 1047-1:+1:-2
61f5c3f5 1048+1:-1:2
1049+9:+1:8
1050+99:+1:98
1051+999:+1:998
1052+9999:+1:9998
1053+99999:+1:99998
1054+999999:+1:999998
1055+9999999:+1:9999998
1056+99999999:+1:99999998
1057+999999999:+1:999999998
1058+9999999999:+1:9999999998
1059+99999999999:+1:99999999998
1060+10:-1:11
1061+100:-1:101
1062+1000:-1:1001
1063+10000:-1:10001
1064+100000:-1:100001
1065+1000000:-1:1000001
1066+10000000:-1:10000001
1067+100000000:-1:100000001
1068+1000000000:-1:1000000001
1069+10000000000:-1:10000000001
6854fd01 1070+123456789:+987654321:-864197532
1071-123456789:+987654321:-1111111110
61f5c3f5 1072-123456789:-987654321:864197532
1073+123456789:-987654321:1111111110
6854fd01 1074&bmul
1075abc:abc:NaN
1076abc:+0:NaN
1077+0:abc:NaN
1078NaNmul:+inf:NaN
1079NaNmul:-inf:NaN
1080-inf:NaNmul:NaN
1081+inf:NaNmul:NaN
1082+inf:+inf:inf
1083+inf:-inf:-inf
1084-inf:+inf:-inf
1085-inf:-inf:inf
61f5c3f5 1086+0:+0:0
1087+0:+1:0
1088+1:+0:0
1089+0:-1:0
1090-1:+0:0
1091123456789123456789:0:0
10920:123456789123456789:0
1093-1:-1:1
6854fd01 1094-1:+1:-1
1095+1:-1:-1
61f5c3f5 1096+1:+1:1
1097+2:+3:6
6854fd01 1098-2:+3:-6
1099+2:-3:-6
61f5c3f5 1100-2:-3:6
1101111:111:12321
110210101:10101:102030201
11031001001:1001001:1002003002001
1104100010001:100010001:10002000300020001
110510000100001:10000100001:100002000030000200001
110611111111111:9:99999999999
110722222222222:9:199999999998
110833333333333:9:299999999997
110944444444444:9:399999999996
111055555555555:9:499999999995
111166666666666:9:599999999994
111277777777777:9:699999999993
111388888888888:9:799999999992
111499999999999:9:899999999991
1115+25:+25:625
1116+12345:+12345:152399025
1117+99999:+11111:1111088889
6854fd01 11189999:10000:99990000
111999999:100000:9999900000
1120999999:1000000:999999000000
11219999999:10000000:99999990000000
112299999999:100000000:9999999900000000
1123999999999:1000000000:999999999000000000
11249999999999:10000000000:99999999990000000000
112599999999999:100000000000:9999999999900000000000
1126999999999999:1000000000000:999999999999000000000000
11279999999999999:10000000000000:99999999999990000000000000
112899999999999999:100000000000000:9999999999999900000000000000
1129999999999999999:1000000000000000:999999999999999000000000000000
11309999999999999999:10000000000000000:99999999999999990000000000000000
113199999999999999999:100000000000000000:9999999999999999900000000000000000
1132999999999999999999:1000000000000000000:999999999999999999000000000000000000
11339999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1134&bdiv-list
1135100:20:5,0
11364095:4095:1,0
1137-4095:-4095:1,0
11384095:-4095:-1,0
1139-4095:4095:-1,0
1140123:2:61,1
b3abae2a 11419:5:1,4
11429:4:2,1
6854fd01 1143# inf handling and general remainder
11445:8:0,5
11450:8:0,0
114611:2:5,1
114711:-2:-5,-1
1148-11:2:-5,1
1149# see table in documentation in MBI
11500:inf:0,0
11510:-inf:0,0
11525:inf:0,5
11535:-inf:0,5
1154-5:inf:0,-5
1155-5:-inf:0,-5
1156inf:5:inf,0
1157-inf:5:-inf,0
1158inf:-5:-inf,0
1159-inf:-5:inf,0
11605:5:1,0
1161-5:-5:1,0
b3abae2a 1162inf:inf:NaN,NaN
1163-inf:-inf:NaN,NaN
1164-inf:inf:NaN,NaN
1165inf:-inf:NaN,NaN
6854fd01 11668:0:inf,8
1167inf:0:inf,inf
1168# exceptions to reminder rule
1169-8:0:-inf,-8
1170-inf:0:-inf,-inf
11710:0:NaN,NaN
1172&bdiv
1173abc:abc:NaN
61f5c3f5 1174abc:1:NaN
11751:abc:NaN
11760:0:NaN
6854fd01 1177# inf handling (see table in doc)
11780:inf:0
11790:-inf:0
11805:inf:0
11815:-inf:0
1182-5:inf:0
1183-5:-inf:0
1184inf:5:inf
1185-inf:5:-inf
1186inf:-5:-inf
1187-inf:-5:inf
11885:5:1
1189-5:-5:1
b3abae2a 1190inf:inf:NaN
1191-inf:-inf:NaN
1192-inf:inf:NaN
1193inf:-inf:NaN
6854fd01 11948:0:inf
1195inf:0:inf
1196-8:0:-inf
1197-inf:0:-inf
11980:0:NaN
119911:2:5
1200-11:-2:5
1201-11:2:-5
120211:-2:-5
61f5c3f5 12030:1:0
12040:-1:0
12051:1:1
1206-1:-1:1
12071:-1:-1
1208-1:1:-1
12091:2:0
12102:1:2
12111:26:0
12121000000000:9:111111111
12132000000000:9:222222222
12143000000000:9:333333333
12154000000000:9:444444444
12165000000000:9:555555555
12176000000000:9:666666666
12187000000000:9:777777777
12198000000000:9:888888888
12209000000000:9:1000000000
122135500000:113:314159
122271000000:226:314159
1223106500000:339:314159
12241000000000:3:333333333
1225+10:+5:2
1226+100:+4:25
1227+1000:+8:125
1228+10000:+16:625
1229999999999999:9:111111111111
1230999999999999:99:10101010101
1231999999999999:999:1001001001
1232999999999999:9999:100010001
1233999999999999999:99999:10000100001
1234+1111088889:99999:11111
6854fd01 1235-5:-3:1
1236-5:3:-1
12374:3:1
12384:-3:-1
12391:3:0
12401:-3:0
1241-2:-3:0
1242-2:3:0
12438:3:2
1244-8:3:-2
124514:-3:-4
1246-14:3:-4
1247-14:-3:4
124814:3:4
1249# bug in Calc with '99999' vs $BASE-1
125010000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
1251&bmod
1252# inf handling, see table in doc
12530:inf:0
12540:-inf:0
12555:inf:5
12565:-inf:5
1257-5:inf:-5
1258-5:-inf:-5
1259inf:5:0
1260-inf:5:0
1261inf:-5:0
1262-inf:-5:0
12635:5:0
1264-5:-5:0
b3abae2a 1265inf:inf:NaN
1266-inf:-inf:NaN
1267-inf:inf:NaN
1268inf:-inf:NaN
6854fd01 12698:0:8
1270inf:0:inf
1271# exceptions to reminder rule
1272-inf:0:-inf
1273-8:0:-8
12740:0:NaN
1275abc:abc:NaN
61f5c3f5 1276abc:1:abc:NaN
12771:abc:NaN
12780:0:NaN
12790:1:0
12801:0:1
12810:-1:0
1282-1:0:-1
12831:1:0
1284-1:-1:0
12851:-1:0
1286-1:1:0
12871:2:1
12882:1:0
12891000000000:9:1
12902000000000:9:2
12913000000000:9:3
12924000000000:9:4
12935000000000:9:5
12946000000000:9:6
12957000000000:9:7
12968000000000:9:8
12979000000000:9:0
129835500000:113:33
129971000000:226:66
1300106500000:339:99
13011000000000:3:1
130210:5:0
1303100:4:0
13041000:8:0
130510000:16:0
1306999999999999:9:0
1307999999999999:99:0
1308999999999999:999:0
1309999999999999:9999:0
1310999999999999999:99999:0
1311-9:+5:1
6854fd01 1312+9:-5:-1
1313-9:-5:-4
1314-5:3:1
1315-2:3:1
13164:3:1
13171:3:1
1318-5:-3:-2
1319-2:-3:-2
13204:-3:-2
13211:-3:-2
13224095:4095:0
027dc388 1323100041000510123:3:0
1324152403346:12345:4321
b3abae2a 13259:5:4
28df3e88 1326# test shortcuts in Calc
1327# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
13281234:9:1
1329123456:9:3
133012345678:9:0
13311234567891:9:1
1332123456789123:9:6
133312345678912345:9:6
13341234567891234567:9:1
1335123456789123456789:9:0
13361234:10:4
1337123456:10:6
133812345678:10:8
13391234567891:10:1
1340123456789123:10:3
134112345678912345:10:5
13421234567891234567:10:7
1343123456789123456789:10:9
13441234:113:104
1345123456:113:60
134612345678:113:89
13471234567891:113:64
1348123456789123:113:95
134912345678912345:113:53
13501234567891234567:113:56
1351123456789123456789:113:39
6854fd01 1352&bgcd
1353abc:abc:NaN
1354abc:+0:NaN
1355+0:abc:NaN
61f5c3f5 1356+0:+0:0
1357+0:+1:1
1358+1:+0:1
1359+1:+1:1
1360+2:+3:1
1361+3:+2:1
1362-3:+2:1
1363100:625:25
13644096:81:1
13651034:804:2
136627:90:56:1
136727:90:54:9
6854fd01 1368&blcm
1369abc:abc:NaN
1370abc:+0:NaN
1371+0:abc:NaN
1372+0:+0:NaN
61f5c3f5 1373+1:+0:0
1374+0:+1:0
1375+27:+90:270
1376+1034:+804:415668
6854fd01 1377&band
1378abc:abc:NaN
1379abc:0:NaN
13800:abc:NaN
13811:2:0
13823:2:2
61f5c3f5 1383+8:+2:0
1384+281474976710656:0:0
1385+281474976710656:1:0
1386+281474976710656:+281474976710656:281474976710656
6854fd01 1387-2:-3:-4
1388-1:-1:-1
1389-6:-6:-6
1390-7:-4:-8
1391-7:4:0
1392-4:7:4
394e6ffb 1393# equal arguments are treated special, so also do some test with unequal ones
13940xFFFF:0xFFFF:0x0xFFFF
13950xFFFFFF:0xFFFFFF:0x0xFFFFFF
13960xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
13970xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
13980xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
13990xF0F0:0xF0F0:0x0xF0F0
14000x0F0F:0x0F0F:0x0x0F0F
14010xF0F0F0:0xF0F0F0:0x0xF0F0F0
14020x0F0F0F:0x0F0F0F:0x0x0F0F0F
14030xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
14040x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
14050xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
14060x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
14070xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
14080x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
14090x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1410&bior
1411abc:abc:NaN
1412abc:0:NaN
14130:abc:NaN
14141:2:3
61f5c3f5 1415+8:+2:10
1416+281474976710656:0:281474976710656
1417+281474976710656:1:281474976710657
1418+281474976710656:281474976710656:281474976710656
6854fd01 1419-2:-3:-1
1420-1:-1:-1
1421-6:-6:-6
1422-7:4:-3
1423-4:7:-1
394e6ffb 1424# equal arguments are treated special, so also do some test with unequal ones
14250xFFFF:0xFFFF:0x0xFFFF
14260xFFFFFF:0xFFFFFF:0x0xFFFFFF
14270xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
14280xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14290xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14300:0xFFFF:0x0xFFFF
14310:0xFFFFFF:0x0xFFFFFF
14320:0xFFFFFFFF:0x0xFFFFFFFF
14330:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14340:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14350xFFFF:0:0x0xFFFF
14360xFFFFFF:0:0x0xFFFFFF
14370xFFFFFFFF:0:0x0xFFFFFFFF
14380xFFFFFFFFFF:0:0x0xFFFFFFFFFF
14390xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
14400xF0F0:0xF0F0:0x0xF0F0
14410x0F0F:0x0F0F:0x0x0F0F
14420xF0F0:0x0F0F:0x0xFFFF
14430xF0F0F0:0xF0F0F0:0x0xF0F0F0
14440x0F0F0F:0x0F0F0F:0x0x0F0F0F
14450x0F0F0F:0xF0F0F0:0x0xFFFFFF
14460xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
14470x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
14480x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
14490xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
14500x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
14510x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
14520xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
14530x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
14540x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
14550x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1456&bxor
1457abc:abc:NaN
1458abc:0:NaN
14590:abc:NaN
14601:2:3
61f5c3f5 1461+8:+2:10
1462+281474976710656:0:281474976710656
1463+281474976710656:1:281474976710657
1464+281474976710656:281474976710656:0
6854fd01 1465-2:-3:3
1466-1:-1:0
1467-6:-6:0
1468-7:4:-3
1469-4:7:-5
14704:-7:-3
1471-4:-7:5
394e6ffb 1472# equal arguments are treated special, so also do some test with unequal ones
14730xFFFF:0xFFFF:0
14740xFFFFFF:0xFFFFFF:0
14750xFFFFFFFF:0xFFFFFFFF:0
14760xFFFFFFFFFF:0xFFFFFFFFFF:0
14770xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
14780:0xFFFF:0x0xFFFF
14790:0xFFFFFF:0x0xFFFFFF
14800:0xFFFFFFFF:0x0xFFFFFFFF
14810:0xFFFFFFFFFF:0x0xFFFFFFFFFF
14820:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
14830xFFFF:0:0x0xFFFF
14840xFFFFFF:0:0x0xFFFFFF
14850xFFFFFFFF:0:0x0xFFFFFFFF
14860xFFFFFFFFFF:0:0x0xFFFFFFFFFF
14870xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
14880xF0F0:0xF0F0:0
14890x0F0F:0x0F0F:0
14900xF0F0:0x0F0F:0x0xFFFF
14910xF0F0F0:0xF0F0F0:0
14920x0F0F0F:0x0F0F0F:0
14930x0F0F0F:0xF0F0F0:0x0xFFFFFF
14940xF0F0F0F0:0xF0F0F0F0:0
14950x0F0F0F0F:0x0F0F0F0F:0
14960x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
14970xF0F0F0F0F0:0xF0F0F0F0F0:0
14980x0F0F0F0F0F:0x0F0F0F0F0F:0
14990x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
15000xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
15010x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
15020x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1503&bnot
1504abc:NaN
1505+0:-1
1506+8:-9
1507+281474976710656:-281474976710657
1508-1:0
1509-2:1
1510-12:11
1511&digit
15120:0:0
151312:0:2
151412:1:1
1515123:0:3
1516123:1:2
1517123:2:1
1518123:-1:1
1519123:-2:2
1520123:-3:3
1521123456:0:6
1522123456:1:5
1523123456:2:4
1524123456:3:3
1525123456:4:2
1526123456:5:1
1527123456:-1:1
1528123456:-2:2
1529123456:-3:3
1530100000:-3:0
1531100000:0:0
1532100000:1:0
1533&mantissa
1534abc:NaN
15351e4:1
15362e0:2
1537123:123
1538-1:-1
1539-2:-2
1540+inf:inf
1541-inf:-inf
1542&exponent
1543abc:NaN
15441e4:4
15452e0:0
1546123:0
1547-1:0
1548-2:0
15490:1
1550+inf:inf
1551-inf:inf
1552&parts
1553abc:NaN,NaN
15541e4:1,4
15552e0:2,0
1556123:123,0
1557-1:-1,0
1558-2:-2,0
15590:0,1
1560+inf:inf,inf
1561-inf:-inf,inf
b3abae2a 1562&bfac
1563-1:NaN
1564NaNfac:NaN
1565+inf:NaN
1566-inf:NaN
15670:1
15681:1
15692:2
15703:6
15714:24
15725:120
15736:720
157410:3628800
157511:39916800
157612:479001600
6854fd01 1577&bpow
1578abc:12:NaN
157912:abc:NaN
15800:0:1
15810:1:0
15820:2:0
15830:-1:NaN
15840:-2:NaN
15851:0:1
15861:1:1
15871:2:1
15881:3:1
15891:-1:1
15901:-2:1
15911:-3:1
15922:0:1
15932:1:2
15942:2:4
15952:3:8
15963:3:27
15972:-1:NaN
1598-2:-1:NaN
15992:-2:NaN
1600-2:-2:NaN
1601+inf:1234500012:inf
1602-inf:1234500012:-inf
1603+inf:-12345000123:inf
1604-inf:-12345000123:-inf
1605# 1 ** -x => 1 / (1 ** x)
1606-1:0:1
1607-2:0:1
1608-1:1:-1
1609-1:2:1
1610-1:3:-1
1611-1:4:1
1612-1:5:-1
1613-1:-1:-1
1614-1:-2:1
1615-1:-3:-1
1616-1:-4:1
161710:2:100
161810:3:1000
161910:4:10000
162010:5:100000
162110:6:1000000
162210:7:10000000
162310:8:100000000
162410:9:1000000000
162510:20:100000000000000000000
1626123456:2:15241383936
1627&length
1628100:3
162910:2
16301:1
16310:1
163212345:5
163310000000000000000:17
1634-123:3
1635215960156869840440586892398248:30
1636&bsqrt
394e6ffb 1637145:12
6854fd01 1638144:12
394e6ffb 1639143:11
6854fd01 164016:4
394e6ffb 1641170:13
1642169:13
1643168:12
6854fd01 16444:2
394e6ffb 16453:1
6854fd01 16462:1
394e6ffb 16479:3
6854fd01 164812:3
1649256:16
1650100000000:10000
16514000000000000:2000000
394e6ffb 1652152399026:12345
1653152399025:12345
1654152399024:12344
6854fd01 16551:1
16560:0
1657-2:NaN
394e6ffb 1658-123:NaN
6854fd01 1659Nan:NaN
394e6ffb 1660+inf:NaN
6854fd01 1661&bround
1662$round_mode('trunc')
16630:12:0
1664NaNbround:12:NaN
1665+inf:12:inf
1666-inf:12:-inf
16671234:0:1234
16681234:2:1200
1669123456:4:123400
1670123456:5:123450
1671123456:6:123456
61f5c3f5 1672+10123456789:5:10123000000
6854fd01 1673-10123456789:5:-10123000000
61f5c3f5 1674+10123456789:9:10123456700
6854fd01 1675-10123456789:9:-10123456700
61f5c3f5 1676+101234500:6:101234000
6854fd01 1677-101234500:6:-101234000
61f5c3f5 1678#+101234500:-4:101234000
6854fd01 1679#-101234500:-4:-101234000
1680$round_mode('zero')
61f5c3f5 1681+20123456789:5:20123000000
6854fd01 1682-20123456789:5:-20123000000
61f5c3f5 1683+20123456789:9:20123456800
6854fd01 1684-20123456789:9:-20123456800
61f5c3f5 1685+201234500:6:201234000
6854fd01 1686-201234500:6:-201234000
61f5c3f5 1687#+201234500:-4:201234000
6854fd01 1688#-201234500:-4:-201234000
1689+12345000:4:12340000
1690-12345000:4:-12340000
1691$round_mode('+inf')
61f5c3f5 1692+30123456789:5:30123000000
6854fd01 1693-30123456789:5:-30123000000
61f5c3f5 1694+30123456789:9:30123456800
6854fd01 1695-30123456789:9:-30123456800
61f5c3f5 1696+301234500:6:301235000
6854fd01 1697-301234500:6:-301234000
61f5c3f5 1698#+301234500:-4:301235000
6854fd01 1699#-301234500:-4:-301234000
1700+12345000:4:12350000
1701-12345000:4:-12340000
1702$round_mode('-inf')
61f5c3f5 1703+40123456789:5:40123000000
6854fd01 1704-40123456789:5:-40123000000
61f5c3f5 1705+40123456789:9:40123456800
6854fd01 1706-40123456789:9:-40123456800
61f5c3f5 1707+401234500:6:401234000
1708+401234500:6:401234000
6854fd01 1709#-401234500:-4:-401235000
1710#-401234500:-4:-401235000
1711+12345000:4:12340000
1712-12345000:4:-12350000
1713$round_mode('odd')
61f5c3f5 1714+50123456789:5:50123000000
6854fd01 1715-50123456789:5:-50123000000
61f5c3f5 1716+50123456789:9:50123456800
6854fd01 1717-50123456789:9:-50123456800
61f5c3f5 1718+501234500:6:501235000
6854fd01 1719-501234500:6:-501235000
61f5c3f5 1720#+501234500:-4:501235000
6854fd01 1721#-501234500:-4:-501235000
1722+12345000:4:12350000
1723-12345000:4:-12350000
1724$round_mode('even')
61f5c3f5 1725+60123456789:5:60123000000
6854fd01 1726-60123456789:5:-60123000000
61f5c3f5 1727+60123456789:9:60123456800
6854fd01 1728-60123456789:9:-60123456800
61f5c3f5 1729+601234500:6:601234000
6854fd01 1730-601234500:6:-601234000
61f5c3f5 1731#+601234500:-4:601234000
6854fd01 1732#-601234500:-4:-601234000
1733#-601234500:-9:0
1734#-501234500:-9:0
1735#-601234500:-8:0
1736#-501234500:-8:0
1737+1234567:7:1234567
1738+1234567:6:1234570
1739+12345000:4:12340000
1740-12345000:4:-12340000
1741&is_zero
17420:1
1743NaNzero:0
1744+inf:0
1745-inf:0
1746123:0
1747-1:0
17481:0
1749&is_one
17500:0
1751NaNone:0
1752+inf:0
1753-inf:0
17541:1
17552:0
1756-1:0
1757-2:0
1758# floor and ceil tests are pretty pointless in integer space...but play safe
1759&bfloor
17600:0
1761NaNfloor:NaN
1762+inf:inf
1763-inf:-inf
1764-1:-1
1765-2:-2
17662:2
17673:3
1768abc:NaN
1769&bceil
1770NaNceil:NaN
1771+inf:inf
1772-inf:-inf
17730:0
1774-1:-1
1775-2:-2
17762:2
17773:3
1778abc:NaN
1779&as_hex
1780128:0x80
1781-128:-0x80
17820:0x0
1783-0:0x0
17841:0x1
17850x123456789123456789:0x123456789123456789
1786+inf:inf
1787-inf:-inf
1788NaNas_hex:NaN
1789&as_bin
1790128:0b10000000
1791-128:-0b10000000
17920:0b0
1793-0:0b0
17941:0b1
17950b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1796+inf:inf
1797-inf:-inf
1798NaNas_bin:NaN