4d74a412ca10a7ff5d4ccb36c31a501ff8b19951
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigintpm.inc
1 #include this file into another for subclass testing
2
3 my $version = ${"$class\::VERSION"};
4
5 ##############################################################################
6 # for testing inheritance of _swap
7
8 package Math::Foo;
9
10 use Math::BigInt lib => $main::CL;
11 use vars qw/@ISA/;
12 @ISA = (qw/Math::BigInt/);
13
14 use 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
19 sub _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 ##############################################################################
35 package main;
36
37 my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
38
39 my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
40
41 while (<DATA>) 
42   {
43   chomp;
44   next if /^#/; # skip comments
45   if (s/^&//) 
46     {
47     $f = $_; next;
48     }
49   elsif (/^\$/) 
50     {
51     $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
52     }
53
54   @args = split(/:/,$_,99); $ans = pop(@args);
55   $expected_class = $class;
56   if ($ans =~ /(.*?)=(.*)/)
57     {
58     $expected_class = $2; $ans = $1;
59     }
60   $try = "\$x = $class->new(\"$args[0]\");";
61   if ($f eq "bnorm")
62     {
63     $try = "\$x = $class->bnorm(\"$args[0]\");";
64   # some is_xxx tests
65    } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
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
78    } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
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") {
100       $try .= "$round_mode; \$x->bround(\$y);";
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));';
113       # overload via x=
114       } elsif ($f =~ /^.=$/){
115       $try .= "\$x $f \$y;";
116       # overload via x
117       } elsif ($f =~ /^.$/){
118       $try .= "\$x $f \$y;";
119       } elsif ($f eq "bmod"){
120       $try .= '$x % $y;';
121       } elsif ($f eq "bgcd")
122         {
123         if (defined $args[2])
124           {
125           $try .= " \$z = $class->new('$args[2]'); ";
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           {
135           $try .= " \$z = $class->new('$args[2]'); ";
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 "bmodinv") {
167        $try .= "\$x->bmodinv(\$y);";
168       }elsif ($f eq "digit"){
169         $try .= "\$x->digit(\$y);";
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       }
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();
185     }
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);
194     ok (ref($ans),$expected_class) if $expected_class ne $class;
195     }
196   # check internal state of number objects
197   is_valid($ans1,$f) if ref $ans1; 
198   } # endwhile data tests
199 close DATA;
200
201 # test some more
202 @a = ();
203 for (my $i = 1; $i < 10; $i++) 
204   {
205   push @a, $i;
206   }
207 ok "@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;
213 print "# 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;
218 print "# 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;
225 ok ($x,3);
226 ok ($y,4);
227 ok ($z,0);
228 $z = $x | $y;
229 ok ($x,3);
230 ok ($y,4);
231 ok ($z,7);
232 $x = $class->new(1);
233 $y = $class->new(2);
234 $z = $x | $y;
235 ok ($x,1);
236 ok ($y,2);
237 ok ($z,3);
238
239 $x = $class->new(5);
240 $y = $class->new(4);
241 $z = $x ^ $y;
242 ok ($x,5);
243 ok ($y,4);
244 ok ($z,1);
245
246 $x = $class->new(-5); $y = -$x;
247 ok ($x, -5);
248
249 $x = $class->new(-5); $y = abs($x);
250 ok ($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;
257 print "# 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 ###############################################################################
263 # check reversed order of arguments
264
265 $try = "\$x = $class->new(10); \$x = 2 ** \$x;";
266 $try .= "'ok' if \$x == 1024;"; $ans = eval $try;
267 print "# 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;
271 print "# 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;
275 print "# 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;
279 print "# 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;
283 print "# For '$try'\n" if (!ok "$ans" , "ok" ); 
284
285 $try = "\$x = $class\->new(3); \$x = 20 % \$x;";
286 $try .= "'ok' if \$x == 2;"; $ans = eval $try;
287 print "# 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;
291 print "# 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;
295 print "# 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;
299 print "# For '$try'\n" if (!ok "$ans" , "ok" ); 
300
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;
307 print "# 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);
322 ok (scalar @args,3);            # $class, 4, 5
323 ok ($args[0] =~ /^Math::BigInt/);
324 ok ($args[1],4);
325 ok ($args[2],5);
326
327 @args = Math::BigInt::objectify(0,4,5);
328 ok (scalar @args,3);            # $class, 4, 5
329 ok ($args[0] =~ /^Math::BigInt/);
330 ok ($args[1],4);
331 ok ($args[2],5);
332
333 @args = Math::BigInt::objectify(2,4,5);
334 ok (scalar @args,3);            # $class, 4, 5
335 ok ($args[0] =~ /^Math::BigInt/);
336 ok ($args[1],4);
337 ok ($args[2],5);
338
339 @args = Math::BigInt::objectify(2,4,5,6,7);
340 ok (scalar @args,5);            # $class, 4, 5, 6, 7
341 ok ($args[0] =~ /^Math::BigInt/);
342 ok ($args[1],4); ok (ref($args[1]),$args[0]);
343 ok ($args[2],5); ok (ref($args[2]),$args[0]);
344 ok ($args[3],6); ok (ref($args[3]),'');
345 ok ($args[4],7); ok (ref($args[4]),'');
346
347 @args = Math::BigInt::objectify(2,$class,4,5,6,7);
348 ok (scalar @args,5);            # $class, 4, 5, 6, 7
349 ok ($args[0],$class);
350 ok ($args[1],4); ok (ref($args[1]),$args[0]);
351 ok ($args[2],5); ok (ref($args[2]),$args[0]);
352 ok ($args[3],6); ok (ref($args[3]),'');
353 ok ($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;
371 ok ($x,"20988936657440586486151264256610222593863921");
372 ok ($x->length(),length "20988936657440586486151264256610222593863921");
373
374 # MM7 = 2^127-1
375 $x = $class->new(2); $x **= 127; $x--;
376 ok ($x,"170141183460469231731687303715884105727");
377
378 $x = $class->new('215960156869840440586892398248');
379 ($x,$y) = $x->length();
380 ok ($x,30); ok ($y,0);
381
382 $x = $class->new('1_000_000_000_000');
383 ($x,$y) = $x->length();
384 ok ($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
400 ok ($x,3);
401 ok (ref($x),'Math::Foo');
402
403 $x = Math::Foo->new(5);
404 $x = 8 - $x;            # 5 - 8 instead of 8 - 5
405 ok ($x,-3);
406 ok (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 ###############################################################################
417 # the followin tests only make sense with Math::BigInt::Calc or BareCalc
418
419 exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al.
420
421 ###############################################################################
422 # check proper length of internal arrays
423
424 my $bl = $CL->_base_len();
425 my $BASE = '9' x $bl;
426 my $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)); 
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);     
441 $x = $class->new(-$BASE);      ok ($x->numify(),-$BASE);
442 $x = $class->new( -($BASE*$BASE*1+$BASE*1+1) ); 
443 ok($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
448 $x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
449 if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
450
451 $x = $class->new($BASE+3); $x++;
452 if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
453
454 # test for +0 instead of int(): 
455 $x = $class->new($MAX); ok ($x->length(), length($MAX));
456
457 ###############################################################################
458 # test bug that $class->digit($string) did not work
459
460 ok ($class->digit(123,2),1);
461
462 ###############################################################################
463 # bug in sub where number with at least 6 trailing zeros after any op failed
464
465 $x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
466 ok ($z, 100000);
467 ok ($x, 23456);
468
469 ###############################################################################
470 # bug in shortcut in mul()
471
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
488
489 ###############################################################################
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
495 ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
496
497  }
498
499 ###############################################################################
500 # bug with rest "-0" in div, causing further div()s to fail
501
502 $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
503
504 ok ($y,'0'); is_valid($y);      # $y not '-0'
505
506 ###############################################################################
507 # bone/binf etc as plain calls (Lite failed them)
508
509 ok ($class->bzero(),0);
510 ok ($class->bone(),1);
511 ok ($class->bone('+'),1);
512 ok ($class->bone('-'),-1);
513 ok ($class->bnan(),'NaN');
514 ok ($class->binf(),'inf');
515 ok ($class->binf('+'),'inf');
516 ok ($class->binf('-'),'-inf');
517 ok ($class->binf('-inf'),'-inf');
518
519 ###############################################################################
520 # all tests done
521
522 1;
523
524 ###############################################################################
525 ###############################################################################
526 # Perl 5.005 does not like ok ($x,undef)
527
528 sub 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
540 sub is_valid
541   {
542   my ($x,$f) = @_;
543
544   my $e = 0;                    # error?
545
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/;
549
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     }
559
560   # test done, see if error did crop up
561   ok (1,1), return if ($e eq '0');
562
563   ok (1,$e." after op '$f'");
564   }
565
566 __DATA__
567 &.=
568 1234:-345:1234-345
569 &+=
570 1:2:3
571 -1:-2:-3
572 &-=
573 1:2:-1
574 -1:-2:1
575 &*=
576 2:3:6
577 -1:5:-5
578 &%=
579 100:3:1
580 8:9:8
581 &/=
582 100:3:33
583 -8:2:-4
584 &|=
585 2:1:3
586 &&=
587 5:7:5
588 &^=
589 5:7:2
590 &is_negative
591 0:0
592 -1:1
593 1:0
594 +inf:0
595 -inf:1
596 NaNneg:0
597 &is_positive
598 0:1
599 -1:0
600 1:1
601 +inf:1
602 -inf:0
603 NaNneg:0
604 &is_int
605 -inf:0
606 +inf:0
607 NaNis_int:0
608 1:1
609 0:1
610 123e12:1
611 &is_odd
612 abc:0
613 0:0
614 1:1
615 3:1
616 -1:1
617 -3:1
618 10000001:1
619 10000002:0
620 2:0
621 120:0
622 121:1
623 &is_even
624 abc:0
625 0:1
626 1:0
627 3:0
628 -1:0
629 -3:0
630 10000001:0
631 10000002:1
632 2:1
633 120:1
634 121:0
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
648 acmpNaN:123:
649 123:acmpNaN:
650 acmpNaN: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:
662 NaN:inf:
663 -inf:NaN:
664 NaN:-inf:
665 &bnorm
666 123:123
667 # binary input
668 0babc:NaN
669 0b123:NaN
670 0b0:0
671 -0b0:0
672 -0b1:-1
673 0b0001:1
674 0b001:1
675 0b011:3
676 0b101:5
677 0b1001:9
678 0b10001:17
679 0b100001:33
680 0b1000001:65
681 0b10000001:129
682 0b100000001:257
683 0b1000000001:513
684 0b10000000001:1025
685 0b100000000001:2049
686 0b1000000000001:4097
687 0b10000000000001:8193
688 0b100000000000001:16385
689 0b1000000000000001:32769
690 0b10000000000000001:65537
691 0b100000000000000001:131073
692 0b1000000000000000001:262145
693 0b10000000000000000001:524289
694 0b100000000000000000001:1048577
695 0b1000000000000000000001:2097153
696 0b10000000000000000000001:4194305
697 0b100000000000000000000001:8388609
698 0b1000000000000000000000001:16777217
699 0b10000000000000000000000001:33554433
700 0b100000000000000000000000001:67108865
701 0b1000000000000000000000000001:134217729
702 0b10000000000000000000000000001:268435457
703 0b100000000000000000000000000001:536870913
704 0b1000000000000000000000000000001:1073741825
705 0b10000000000000000000000000000001:2147483649
706 0b100000000000000000000000000000001:4294967297
707 0b1000000000000000000000000000000001:8589934593
708 0b10000000000000000000000000000000001:17179869185
709 0b_101:NaN
710 0b1_0_1:5
711 0b0_0_0_1:1
712 # hex input
713 -0x0:0
714 0xabcdefgh:NaN
715 0x1234:4660
716 0xabcdef:11259375
717 -0xABCDEF:-11259375
718 -0x1234:-4660
719 0x12345678:305419896
720 0x1_2_3_4_56_78:305419896
721 0xa_b_c_d_e_f:11259375
722 0x_123:NaN
723 0x9:9
724 0x11:17
725 0x21:33
726 0x41:65
727 0x81:129
728 0x101:257
729 0x201:513
730 0x401:1025
731 0x801:2049
732 0x1001:4097
733 0x2001:8193
734 0x4001:16385
735 0x8001:32769
736 0x10001:65537
737 0x20001:131073
738 0x40001:262145
739 0x80001:524289
740 0x100001:1048577
741 0x200001:2097153
742 0x400001:4194305
743 0x800001:8388609
744 0x1000001:16777217
745 0x2000001:33554433
746 0x4000001:67108865
747 0x8000001:134217729
748 0x10000001:268435457
749 0x20000001:536870913
750 0x40000001:1073741825
751 0x80000001:2147483649
752 0x100000001:4294967297
753 0x200000001:8589934593
754 0x400000001:17179869185
755 0x800000001:34359738369
756 # inf input
757 inf:inf
758 +inf:inf
759 -inf:-inf
760 0inf:NaN
761 # abnormal input
762 :NaN
763 abc:NaN
764    1 a:NaN
765 1bcd2:NaN
766 11111b:NaN
767 +1z:NaN
768 -1z:NaN
769 # only one underscore between two digits
770 _123:NaN
771 _123_:NaN
772 123_:NaN
773 1__23:NaN
774 1E1__2:NaN
775 1_E12:NaN
776 1E_12:NaN
777 1_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
783 E1:NaN
784 E23:NaN
785 1.23E1:NaN
786 1.23E-1:NaN
787 # bug with two E's in number beeing valid
788 1e2e3:NaN
789 1e2r:NaN
790 1e2.0:NaN
791 # leading zeros
792 012:12
793 0123:123
794 01234:1234
795 012345:12345
796 0123456:123456
797 01234567:1234567
798 012345678:12345678
799 0123456789:123456789
800 01234567891:1234567891
801 012345678912:12345678912
802 0123456789123:123456789123
803 01234567891234:1234567891234
804 # normal input
805 0:0
806 +0:0
807 +00:0
808 +000:0
809 000000000000000000:0
810 -0:0
811 -0000:0
812 +1:1
813 +01:1
814 +001:1
815 +00000100000:100000
816 123456789:123456789
817 -1:-1
818 -01:-1
819 -001:-1
820 -123456789:-123456789
821 -00000100000:-100000
822 1_2_3:123
823 10000000000E-1_0:1
824 1E2:100
825 1E1:10
826 1E0:1
827 1.23E2:123
828 100E-1:10
829 # floating point input
830 # .2e2:20
831 1.E3:1000
832 1.01E2:101
833 1010E-1:101
834 -1010E0:-1010
835 -1010E1:-10100
836 1234.00:1234
837 # non-integer numbers
838 -1010E-2:NaN
839 -1.01E+1:NaN
840 -1.01E-1:NaN
841 &bnan
842 1:NaN
843 2:NaN
844 abc:NaN
845 &bone
846 2:+:1
847 2:-:-1
848 boneNaN:-:-1
849 boneNaN:+:1
850 2:abc:1
851 3::1
852 &binf
853 1:+:inf
854 2:-:-inf
855 3:abc:inf
856 &is_nan
857 123:0
858 abc:1
859 NaN:1
860 -123:0
861 &is_inf
862 +inf::1
863 -inf::1
864 abc::0
865 1::0
866 NaN::0
867 -1::0
868 +inf:-:0
869 +inf:+:1
870 -inf:-:1
871 -inf:+:0
872 -inf:-inf:1
873 -inf:+inf:0
874 +inf:-inf:0
875 +inf:+inf:1
876 # it must be exactly /^[+-]inf$/
877 +infinity::0
878 -infinity::0
879 &blsft
880 abc:abc:NaN
881 +2:+2:8
882 +1:+32:4294967296
883 +1:+48:281474976710656
884 +8:-2:NaN
885 # excercise base 10
886 +12345:4:10:123450000
887 -1234:0:10:-1234
888 +1234:0:10:1234
889 +2:2:10:200
890 +12:2:10:1200
891 +1234:-3:10:NaN
892 1234567890123:12:10:1234567890123000000000000
893 -3:1:2:-6
894 -5:1:2:-10
895 -2:1:2:-4
896 -102533203:1:2:-205066406
897 &brsft
898 abc:abc:NaN
899 +8:+2:2
900 +4294967296:+32:1
901 +281474976710656:+48:1
902 +2:-2:NaN
903 # excercise base 10
904 -1234:0:10:-1234
905 +1234:0:10:1234
906 +200:2:10:2
907 +1234:3:10:1
908 +1234:2:10:12
909 +1234:-3:10:NaN
910 310000:4:10:31
911 12300000:5:10:123
912 1230000000000:10:10:123
913 09876123456789067890:12:10:9876123
914 1234561234567890123:13:10:123456
915 820265627: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
936 &bsstr
937 1e+34:1e+34
938 123.456E3:123456e+0
939 100:1e+2
940 abc:NaN
941 &bneg
942 bnegNaN:NaN
943 +inf:-inf
944 -inf:inf
945 abd:NaN
946 0:0
947 1:-1
948 -1:1
949 +123456789:-123456789
950 -123456789:123456789
951 &babs
952 babsNaN:NaN
953 +inf:inf
954 -inf:inf
955 0:0
956 1:1
957 -1:1
958 +123456789:123456789
959 -123456789:123456789
960 &bcmp
961 bcmpNaN:bcmpNaN:
962 bcmpNaN:0:
963 0:bcmpNaN:
964 0:0:0
965 -1:0:-1
966 0:-1:1
967 1:0:1
968 0:1:-1
969 -1:1:-1
970 1:-1:1
971 -1:-1:0
972 1:1:0
973 123:123:0
974 123:12:1
975 12:123:-1
976 -123:-123:0
977 -123:-12:-1
978 -12:-123:1
979 123:124:-1
980 124:123:1
981 -123:-124:1
982 -124:-123:-1
983 100:5:1
984 -123456789:987654321:-1
985 +123456789:-987654321:1
986 -987654321:123456789:-1
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
995 5:inf:-1
996 5:inf:-1
997 -5:-inf:1
998 -5:-inf:1
999 # return undef
1000 +inf:NaN:
1001 NaN:inf:
1002 -inf:NaN:
1003 NaN:-inf:
1004 &binc
1005 abc:NaN
1006 +inf:inf
1007 -inf:-inf
1008 +0:1
1009 +1:2
1010 -1:0
1011 &bdec
1012 abc:NaN
1013 +inf:inf
1014 -inf:-inf
1015 +0:-1
1016 +1:0
1017 -1:-2
1018 &badd
1019 abc:abc:NaN
1020 abc:0:NaN
1021 +0:abc:NaN
1022 +inf:-inf:NaN
1023 -inf:+inf:NaN
1024 +inf:+inf:inf
1025 -inf:-inf:-inf
1026 baddNaN:+inf:NaN
1027 baddNaN:+inf:NaN
1028 +inf:baddNaN:NaN
1029 -inf:baddNaN:NaN
1030 0:0:0
1031 1:0:1
1032 0:1:1
1033 1:1:2
1034 -1:0:-1
1035 0:-1:-1
1036 -1:-1:-2
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
1062 -123456789:-987654321:-1111111110
1063 +123456789:-987654321:-864197532
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
1084 &bsub
1085 abc:abc:NaN
1086 abc:+0:NaN
1087 +0:abc:NaN
1088 +inf:-inf:inf
1089 -inf:+inf:-inf
1090 +inf:+inf:NaN
1091 -inf:-inf:NaN
1092 +0:+0:0
1093 +1:+0:1
1094 +0:+1:-1
1095 +1:+1:0
1096 -1:+0:-1
1097 +0:-1:1
1098 -1:-1:0
1099 -1:+1:-2
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
1122 +123456789:+987654321:-864197532
1123 -123456789:+987654321:-1111111110
1124 -123456789:-987654321:864197532
1125 +123456789:-987654321:1111111110
1126 10001:1:10000
1127 100001:1:100000
1128 1000001:1:1000000
1129 10000001:1:10000000
1130 100000001:1:100000000
1131 1000000001:1:1000000000
1132 10000000001:1:10000000000
1133 100000000001:1:100000000000
1134 1000000000001:1:1000000000000
1135 10000000000001:1:10000000000000
1136 10001:-1:10002
1137 100001:-1:100002
1138 1000001:-1:1000002
1139 10000001:-1:10000002
1140 100000001:-1:100000002
1141 1000000001:-1:1000000002
1142 10000000001:-1:10000000002
1143 100000000001:-1:100000000002
1144 1000000000001:-1:1000000000002
1145 10000000000001:-1:10000000000002
1146 &bmul
1147 abc:abc:NaN
1148 abc:+0:NaN
1149 +0:abc:NaN
1150 NaNmul:+inf:NaN
1151 NaNmul:-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
1158 +0:+0:0
1159 +0:+1:0
1160 +1:+0:0
1161 +0:-1:0
1162 -1:+0:0
1163 123456789123456789:0:0
1164 0:123456789123456789:0
1165 -1:-1:1
1166 -1:+1:-1
1167 +1:-1:-1
1168 +1:+1:1
1169 +2:+3:6
1170 -2:+3:-6
1171 +2:-3:-6
1172 -2:-3:6
1173 111:111:12321
1174 10101:10101:102030201
1175 1001001:1001001:1002003002001
1176 100010001:100010001:10002000300020001
1177 10000100001:10000100001:100002000030000200001
1178 11111111111:9:99999999999
1179 22222222222:9:199999999998
1180 33333333333:9:299999999997
1181 44444444444:9:399999999996
1182 55555555555:9:499999999995
1183 66666666666:9:599999999994
1184 77777777777:9:699999999993
1185 88888888888:9:799999999992
1186 99999999999:9:899999999991
1187 +25:+25:625
1188 +12345:+12345:152399025
1189 +99999:+11111:1111088889
1190 9999:10000:99990000
1191 99999:100000:9999900000
1192 999999:1000000:999999000000
1193 9999999:10000000:99999990000000
1194 99999999:100000000:9999999900000000
1195 999999999:1000000000:999999999000000000
1196 9999999999:10000000000:99999999990000000000
1197 99999999999:100000000000:9999999999900000000000
1198 999999999999:1000000000000:999999999999000000000000
1199 9999999999999:10000000000000:99999999999990000000000000
1200 99999999999999:100000000000000:9999999999999900000000000000
1201 999999999999999:1000000000000000:999999999999999000000000000000
1202 9999999999999999:10000000000000000:99999999999999990000000000000000
1203 99999999999999999:100000000000000000:9999999999999999900000000000000000
1204 999999999999999999:1000000000000000000:999999999999999999000000000000000000
1205 9999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1206 &bdiv-list
1207 100:20:5,0
1208 4095:4095:1,0
1209 -4095:-4095:1,0
1210 4095:-4095:-1,0
1211 -4095:4095:-1,0
1212 123:2:61,1
1213 9:5:1,4
1214 9:4:2,1
1215 # inf handling and general remainder
1216 5:8:0,5
1217 0:8:0,0
1218 11:2:5,1
1219 11:-2:-5,-1
1220 -11:2:-5,1
1221 # see table in documentation in MBI
1222 0:inf:0,0
1223 0:-inf:0,0
1224 5:inf:0,5
1225 5:-inf:0,5
1226 -5:inf:0,-5
1227 -5:-inf:0,-5
1228 inf:5:inf,0
1229 -inf:5:-inf,0
1230 inf:-5:-inf,0
1231 -inf:-5:inf,0
1232 5:5:1,0
1233 -5:-5:1,0
1234 inf:inf:NaN,NaN
1235 -inf:-inf:NaN,NaN
1236 -inf:inf:NaN,NaN
1237 inf:-inf:NaN,NaN
1238 8:0:inf,8
1239 inf:0:inf,inf
1240 # exceptions to reminder rule
1241 -8:0:-inf,-8
1242 -inf:0:-inf,-inf
1243 0:0:NaN,NaN
1244 &bdiv
1245 abc:abc:NaN
1246 abc:1:NaN
1247 1:abc:NaN
1248 0:0:NaN
1249 # inf handling (see table in doc)
1250 0:inf:0
1251 0:-inf:0
1252 5:inf:0
1253 5:-inf:0
1254 -5:inf:0
1255 -5:-inf:0
1256 inf:5:inf
1257 -inf:5:-inf
1258 inf:-5:-inf
1259 -inf:-5:inf
1260 5:5:1
1261 -5:-5:1
1262 inf:inf:NaN
1263 -inf:-inf:NaN
1264 -inf:inf:NaN
1265 inf:-inf:NaN
1266 8:0:inf
1267 inf:0:inf
1268 -8:0:-inf
1269 -inf:0:-inf
1270 0:0:NaN
1271 11:2:5
1272 -11:-2:5
1273 -11:2:-5
1274 11:-2:-5
1275 0:1:0
1276 0:-1:0
1277 1:1:1
1278 -1:-1:1
1279 1:-1:-1
1280 -1:1:-1
1281 1:2:0
1282 2:1:2
1283 1:26:0
1284 1000000000:9:111111111
1285 2000000000:9:222222222
1286 3000000000:9:333333333
1287 4000000000:9:444444444
1288 5000000000:9:555555555
1289 6000000000:9:666666666
1290 7000000000:9:777777777
1291 8000000000:9:888888888
1292 9000000000:9:1000000000
1293 35500000:113:314159
1294 71000000:226:314159
1295 106500000:339:314159
1296 1000000000:3:333333333
1297 +10:+5:2
1298 +100:+4:25
1299 +1000:+8:125
1300 +10000:+16:625
1301 999999999999:9:111111111111
1302 999999999999:99:10101010101
1303 999999999999:999:1001001001
1304 999999999999:9999:100010001
1305 999999999999999:99999:10000100001
1306 +1111088889:99999:11111
1307 -5:-3:1
1308 -5:3:-1
1309 4:3:1
1310 4:-3:-1
1311 1:3:0
1312 1:-3:0
1313 -2:-3:0
1314 -2:3:0
1315 8:3:2
1316 -8:3:-2
1317 14:-3:-4
1318 -14:3:-4
1319 -14:-3:4
1320 14:3:4
1321 # bug in Calc with '99999' vs $BASE-1
1322 10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
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
1359 &bmod
1360 # inf handling, see table in doc
1361 0:inf:0
1362 0:-inf:0
1363 5:inf:5
1364 5:-inf:5
1365 -5:inf:-5
1366 -5:-inf:-5
1367 inf:5:0
1368 -inf:5:0
1369 inf:-5:0
1370 -inf:-5:0
1371 5:5:0
1372 -5:-5:0
1373 inf:inf:NaN
1374 -inf:-inf:NaN
1375 -inf:inf:NaN
1376 inf:-inf:NaN
1377 8:0:8
1378 inf:0:inf
1379 # exceptions to reminder rule
1380 -inf:0:-inf
1381 -8:0:-8
1382 0:0:NaN
1383 abc:abc:NaN
1384 abc:1:abc:NaN
1385 1:abc:NaN
1386 0:0:NaN
1387 0:1:0
1388 1:0:1
1389 0:-1:0
1390 -1:0:-1
1391 1:1:0
1392 -1:-1:0
1393 1:-1:0
1394 -1:1:0
1395 1:2:1
1396 2:1:0
1397 1000000000:9:1
1398 2000000000:9:2
1399 3000000000:9:3
1400 4000000000:9:4
1401 5000000000:9:5
1402 6000000000:9:6
1403 7000000000:9:7
1404 8000000000:9:8
1405 9000000000:9:0
1406 35500000:113:33
1407 71000000:226:66
1408 106500000:339:99
1409 1000000000:3:1
1410 10:5:0
1411 100:4:0
1412 1000:8:0
1413 10000:16:0
1414 999999999999:9:0
1415 999999999999:99:0
1416 999999999999:999:0
1417 999999999999:9999:0
1418 999999999999999:99999:0
1419 -9:+5:1
1420 +9:-5:-1
1421 -9:-5:-4
1422 -5:3:1
1423 -2:3:1
1424 4:3:1
1425 1:3:1
1426 -5:-3:-2
1427 -2:-3:-2
1428 4:-3:-2
1429 1:-3:-2
1430 4095:4095:0
1431 100041000510123:3:0
1432 152403346:12345:4321
1433 9:5:4
1434 # test shortcuts in Calc
1435 # 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
1436 1234:9:1
1437 123456:9:3
1438 12345678:9:0
1439 1234567891:9:1
1440 123456789123:9:6
1441 12345678912345:9:6
1442 1234567891234567:9:1
1443 123456789123456789:9:0
1444 1234:10:4
1445 123456:10:6
1446 12345678:10:8
1447 1234567891:10:1
1448 123456789123:10:3
1449 12345678912345:10:5
1450 1234567891234567:10:7
1451 123456789123456789:10:9
1452 1234:113:104
1453 123456:113:60
1454 12345678:113:89
1455 1234567891:113:64
1456 123456789123:113:95
1457 12345678912345:113:53
1458 1234567891234567:113:56
1459 123456789123456789:113:39
1460 &bgcd
1461 abc:abc:NaN
1462 abc:+0:NaN
1463 +0:abc:NaN
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
1471 100:625:25
1472 4096:81:1
1473 1034:804:2
1474 27:90:56:1
1475 27:90:54:9
1476 &blcm
1477 abc:abc:NaN
1478 abc:+0:NaN
1479 +0:abc:NaN
1480 +0:+0:NaN
1481 +1:+0:0
1482 +0:+1:0
1483 +27:+90:270
1484 +1034:+804:415668
1485 &band
1486 abc:abc:NaN
1487 abc:0:NaN
1488 0:abc:NaN
1489 1:2:0
1490 3:2:2
1491 +8:+2:0
1492 +281474976710656:0:0
1493 +281474976710656:1:0
1494 +281474976710656:+281474976710656:281474976710656
1495 -2:-3:-4
1496 -1:-1:-1
1497 -6:-6:-6
1498 -7:-4:-8
1499 -7:4:0
1500 -4:7:4
1501 # equal arguments are treated special, so also do some test with unequal ones
1502 0xFFFF:0xFFFF:0x0xFFFF
1503 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1504 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1505 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1506 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1507 0xF0F0:0xF0F0:0x0xF0F0
1508 0x0F0F:0x0F0F:0x0x0F0F
1509 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1510 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1511 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1512 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1513 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1514 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1515 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1516 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1517 0x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
1518 &bior
1519 abc:abc:NaN
1520 abc:0:NaN
1521 0:abc:NaN
1522 1:2:3
1523 +8:+2:10
1524 +281474976710656:0:281474976710656
1525 +281474976710656:1:281474976710657
1526 +281474976710656:281474976710656:281474976710656
1527 -2:-3:-1
1528 -1:-1:-1
1529 -6:-6:-6
1530 -7:4:-3
1531 -4:7:-1
1532 # equal arguments are treated special, so also do some test with unequal ones
1533 0xFFFF:0xFFFF:0x0xFFFF
1534 0xFFFFFF:0xFFFFFF:0x0xFFFFFF
1535 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
1536 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1537 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1538 0:0xFFFF:0x0xFFFF
1539 0:0xFFFFFF:0x0xFFFFFF
1540 0:0xFFFFFFFF:0x0xFFFFFFFF
1541 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1542 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1543 0xFFFF:0:0x0xFFFF
1544 0xFFFFFF:0:0x0xFFFFFF
1545 0xFFFFFFFF:0:0x0xFFFFFFFF
1546 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
1547 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
1548 0xF0F0:0xF0F0:0x0xF0F0
1549 0x0F0F:0x0F0F:0x0x0F0F
1550 0xF0F0:0x0F0F:0x0xFFFF
1551 0xF0F0F0:0xF0F0F0:0x0xF0F0F0
1552 0x0F0F0F:0x0F0F0F:0x0x0F0F0F
1553 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
1554 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
1555 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
1556 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
1557 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
1558 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
1559 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
1560 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
1561 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
1562 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1563 0x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1564 &bxor
1565 abc:abc:NaN
1566 abc:0:NaN
1567 0:abc:NaN
1568 1:2:3
1569 +8:+2:10
1570 +281474976710656:0:281474976710656
1571 +281474976710656:1:281474976710657
1572 +281474976710656:281474976710656:0
1573 -2:-3:3
1574 -1:-1:0
1575 -6:-6:0
1576 -7:4:-3
1577 -4:7:-5
1578 4:-7:-3
1579 -4:-7:5
1580 # equal arguments are treated special, so also do some test with unequal ones
1581 0xFFFF:0xFFFF:0
1582 0xFFFFFF:0xFFFFFF:0
1583 0xFFFFFFFF:0xFFFFFFFF:0
1584 0xFFFFFFFFFF:0xFFFFFFFFFF:0
1585 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
1586 0:0xFFFF:0x0xFFFF
1587 0:0xFFFFFF:0x0xFFFFFF
1588 0:0xFFFFFFFF:0x0xFFFFFFFF
1589 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF
1590 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
1591 0xFFFF:0:0x0xFFFF
1592 0xFFFFFF:0:0x0xFFFFFF
1593 0xFFFFFFFF:0:0x0xFFFFFFFF
1594 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF
1595 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
1596 0xF0F0:0xF0F0:0
1597 0x0F0F:0x0F0F:0
1598 0xF0F0:0x0F0F:0x0xFFFF
1599 0xF0F0F0:0xF0F0F0:0
1600 0x0F0F0F:0x0F0F0F:0
1601 0x0F0F0F:0xF0F0F0:0x0xFFFFFF
1602 0xF0F0F0F0:0xF0F0F0F0:0
1603 0x0F0F0F0F:0x0F0F0F0F:0
1604 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
1605 0xF0F0F0F0F0:0xF0F0F0F0F0:0
1606 0x0F0F0F0F0F:0x0F0F0F0F0F:0
1607 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
1608 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
1609 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
1610 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
1611 &bnot
1612 abc:NaN
1613 +0:-1
1614 +8:-9
1615 +281474976710656:-281474976710657
1616 -1:0
1617 -2:1
1618 -12:11
1619 &digit
1620 0:0:0
1621 12:0:2
1622 12:1:1
1623 123:0:3
1624 123:1:2
1625 123:2:1
1626 123:-1:1
1627 123:-2:2
1628 123:-3:3
1629 123456:0:6
1630 123456:1:5
1631 123456:2:4
1632 123456:3:3
1633 123456:4:2
1634 123456:5:1
1635 123456:-1:1
1636 123456:-2:2
1637 123456:-3:3
1638 100000:-3:0
1639 100000:0:0
1640 100000:1:0
1641 &mantissa
1642 abc:NaN
1643 1e4:1
1644 2e0:2
1645 123:123
1646 -1:-1
1647 -2:-2
1648 +inf:inf
1649 -inf:-inf
1650 &exponent
1651 abc:NaN
1652 1e4:4
1653 2e0:0
1654 123:0
1655 -1:0
1656 -2:0
1657 0:1
1658 +inf:inf
1659 -inf:inf
1660 &parts
1661 abc:NaN,NaN
1662 1e4:1,4
1663 2e0:2,0
1664 123:123,0
1665 -1:-1,0
1666 -2:-2,0
1667 0:0,1
1668 +inf:inf,inf
1669 -inf:-inf,inf
1670 &bfac
1671 -1:NaN
1672 NaNfac:NaN
1673 +inf:NaN
1674 -inf:NaN
1675 0:1
1676 1:1
1677 2:2
1678 3:6
1679 4:24
1680 5:120
1681 6:720
1682 10:3628800
1683 11:39916800
1684 12:479001600
1685 &bpow
1686 abc:12:NaN
1687 12:abc:NaN
1688 0:0:1
1689 0:1:0
1690 0:2:0
1691 0:-1:NaN
1692 0:-2:NaN
1693 1:0:1
1694 1:1:1
1695 1:2:1
1696 1:3:1
1697 1:-1:1
1698 1:-2:1
1699 1:-3:1
1700 2:0:1
1701 2:1:2
1702 2:2:4
1703 2:3:8
1704 3:3:27
1705 2:-1:NaN
1706 -2:-1:NaN
1707 2:-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
1725 10:2:100
1726 10:3:1000
1727 10:4:10000
1728 10:5:100000
1729 10:6:1000000
1730 10:7:10000000
1731 10:8:100000000
1732 10:9:1000000000
1733 10:20:100000000000000000000
1734 123456:2:15241383936
1735 &length
1736 100:3
1737 10:2
1738 1:1
1739 0:1
1740 12345:5
1741 10000000000000000:17
1742 -123:3
1743 215960156869840440586892398248:30
1744 &bsqrt
1745 145:12
1746 144:12
1747 143:11
1748 16:4
1749 170:13
1750 169:13
1751 168:12
1752 4:2
1753 3:1
1754 2:1
1755 9:3
1756 12:3
1757 256:16
1758 100000000:10000
1759 4000000000000:2000000
1760 152399026:12345
1761 152399025:12345
1762 152399024:12344
1763 1:1
1764 0:0
1765 -2:NaN
1766 -123:NaN
1767 Nan:NaN
1768 +inf:NaN
1769 &bround
1770 $round_mode('trunc')
1771 0:12:0
1772 NaNbround:12:NaN
1773 +inf:12:inf
1774 -inf:12:-inf
1775 1234:0:1234
1776 1234:2:1200
1777 123456:4:123400
1778 123456:5:123450
1779 123456:6:123456
1780 +10123456789:5:10123000000
1781 -10123456789:5:-10123000000
1782 +10123456789:9:10123456700
1783 -10123456789:9:-10123456700
1784 +101234500:6:101234000
1785 -101234500:6:-101234000
1786 #+101234500:-4:101234000
1787 #-101234500:-4:-101234000
1788 $round_mode('zero')
1789 +20123456789:5:20123000000
1790 -20123456789:5:-20123000000
1791 +20123456789:9:20123456800
1792 -20123456789:9:-20123456800
1793 +201234500:6:201234000
1794 -201234500:6:-201234000
1795 #+201234500:-4:201234000
1796 #-201234500:-4:-201234000
1797 +12345000:4:12340000
1798 -12345000:4:-12340000
1799 $round_mode('+inf')
1800 +30123456789:5:30123000000
1801 -30123456789:5:-30123000000
1802 +30123456789:9:30123456800
1803 -30123456789:9:-30123456800
1804 +301234500:6:301235000
1805 -301234500:6:-301234000
1806 #+301234500:-4:301235000
1807 #-301234500:-4:-301234000
1808 +12345000:4:12350000
1809 -12345000:4:-12340000
1810 $round_mode('-inf')
1811 +40123456789:5:40123000000
1812 -40123456789:5:-40123000000
1813 +40123456789:9:40123456800
1814 -40123456789:9:-40123456800
1815 +401234500:6:401234000
1816 +401234500:6:401234000
1817 #-401234500:-4:-401235000
1818 #-401234500:-4:-401235000
1819 +12345000:4:12340000
1820 -12345000:4:-12350000
1821 $round_mode('odd')
1822 +50123456789:5:50123000000
1823 -50123456789:5:-50123000000
1824 +50123456789:9:50123456800
1825 -50123456789:9:-50123456800
1826 +501234500:6:501235000
1827 -501234500:6:-501235000
1828 #+501234500:-4:501235000
1829 #-501234500:-4:-501235000
1830 +12345000:4:12350000
1831 -12345000:4:-12350000
1832 $round_mode('even')
1833 +60123456789:5:60123000000
1834 -60123456789:5:-60123000000
1835 +60123456789:9:60123456800
1836 -60123456789:9:-60123456800
1837 +601234500:6:601234000
1838 -601234500:6:-601234000
1839 #+601234500:-4:601234000
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
1850 0:1
1851 NaNzero:0
1852 +inf:0
1853 -inf:0
1854 123:0
1855 -1:0
1856 1:0
1857 &is_one
1858 0:0
1859 NaNone:0
1860 +inf:0
1861 -inf:0
1862 1:1
1863 2:0
1864 -1:0
1865 -2:0
1866 # floor and ceil tests are pretty pointless in integer space...but play safe
1867 &bfloor
1868 0:0
1869 NaNfloor:NaN
1870 +inf:inf
1871 -inf:-inf
1872 -1:-1
1873 -2:-2
1874 2:2
1875 3:3
1876 abc:NaN
1877 &bceil
1878 NaNceil:NaN
1879 +inf:inf
1880 -inf:-inf
1881 0:0
1882 -1:-1
1883 -2:-2
1884 2:2
1885 3:3
1886 abc:NaN
1887 &as_hex
1888 128:0x80
1889 -128:-0x80
1890 0:0x0
1891 -0:0x0
1892 1:0x1
1893 0x123456789123456789:0x123456789123456789
1894 +inf:inf
1895 -inf:-inf
1896 NaNas_hex:NaN
1897 &as_bin
1898 128:0b10000000
1899 -128:-0b10000000
1900 0:0b0
1901 -0:0b0
1902 1:0b1
1903 0b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1904 +inf:inf
1905 -inf:-inf
1906 NaNas_bin:NaN