Upgrade to Math::BigInt 1.66.
[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
56d9de68 5use strict;
6
6854fd01 7##############################################################################
8# for testing inheritance of _swap
9
10package Math::Foo;
11
61f5c3f5 12use Math::BigInt lib => $main::CL;
6854fd01 13use vars qw/@ISA/;
14@ISA = (qw/Math::BigInt/);
15
16use overload
17# customized overload for sub, since original does not use swap there
18'-' => sub { my @a = ref($_[0])->_swap(@_);
19 $a[0]->bsub($a[1])};
20
21sub _swap
22 {
23 # a fake _swap, which reverses the params
24 my $self = shift; # for override in subclass
25 if ($_[2])
26 {
27 my $c = ref ($_[0] ) || 'Math::Foo';
28 return ( $_[0]->copy(), $_[1] );
29 }
30 else
31 {
32 return ( Math::Foo->new($_[1]), $_[0] );
33 }
34 }
35
36##############################################################################
37package main;
38
b3abae2a 39my $CALC = $class->config()->{lib}; ok ($CALC,$CL);
6854fd01 40
b3abae2a 41my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
6854fd01 42
43while (<DATA>)
44 {
d614cd8b 45 chomp;
6854fd01 46 next if /^#/; # skip comments
47 if (s/^&//)
48 {
61f5c3f5 49 $f = $_; next;
6854fd01 50 }
51 elsif (/^\$/)
52 {
61f5c3f5 53 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
6854fd01 54 }
61f5c3f5 55
56 @args = split(/:/,$_,99); $ans = pop(@args);
b3abae2a 57 $expected_class = $class;
58 if ($ans =~ /(.*?)=(.*)/)
59 {
60 $expected_class = $2; $ans = $1;
61 }
61f5c3f5 62 $try = "\$x = $class->new(\"$args[0]\");";
63 if ($f eq "bnorm")
6854fd01 64 {
61f5c3f5 65 $try = "\$x = $class->bnorm(\"$args[0]\");";
66 # some is_xxx tests
b3abae2a 67 } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) {
56d9de68 68 $try .= "\$x->$f() || 0;";
61f5c3f5 69 } elsif ($f eq "is_inf") {
70 $try .= "\$x->is_inf('$args[1]');";
71 } elsif ($f eq "binf") {
72 $try .= "\$x->binf('$args[1]');";
73 } elsif ($f eq "bone") {
74 $try .= "\$x->bone('$args[1]');";
56d9de68 75 # some unary ops
b3abae2a 76 } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) {
61f5c3f5 77 $try .= "\$x->$f();";
56d9de68 78 } elsif ($f =~ /^(numify|length|stringify|as_hex|as_bin)$/) {
79 $try .= "\$x->$f();";
61f5c3f5 80 } elsif ($f eq "exponent"){
81 # ->bstr() to see if an object is returned
82 $try .= '$x = $x->exponent()->bstr();';
83 } elsif ($f eq "mantissa"){
84 # ->bstr() to see if an object is returned
85 $try .= '$x = $x->mantissa()->bstr();';
86 } elsif ($f eq "parts"){
87 $try .= '($m,$e) = $x->parts();';
88 # ->bstr() to see if an object is returned
89 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
90 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
91 $try .= '"$m,$e";';
92 } else {
56d9de68 93 # binary ops
61f5c3f5 94 $try .= "\$y = $class->new('$args[1]');";
95 if ($f eq "bcmp")
96 {
97 $try .= '$x <=> $y;';
98 } elsif ($f eq "bround") {
6854fd01 99 $try .= "$round_mode; \$x->bround(\$y);";
61f5c3f5 100 } elsif ($f eq "bacmp"){
101 $try .= '$x->bacmp($y);';
102 } elsif ($f eq "badd"){
103 $try .= '$x + $y;';
104 } elsif ($f eq "bsub"){
105 $try .= '$x - $y;';
106 } elsif ($f eq "bmul"){
107 $try .= '$x * $y;';
108 } elsif ($f eq "bdiv"){
109 $try .= '$x / $y;';
110 } elsif ($f eq "bdiv-list"){
111 $try .= 'join (",",$x->bdiv($y));';
027dc388 112 # overload via x=
61f5c3f5 113 } elsif ($f =~ /^.=$/){
114 $try .= "\$x $f \$y;";
027dc388 115 # overload via x
61f5c3f5 116 } elsif ($f =~ /^.$/){
117 $try .= "\$x $f \$y;";
118 } elsif ($f eq "bmod"){
119 $try .= '$x % $y;';
120 } elsif ($f eq "bgcd")
6854fd01 121 {
122 if (defined $args[2])
123 {
61f5c3f5 124 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 125 }
126 $try .= "$class\::bgcd(\$x, \$y";
127 $try .= ", \$z" if (defined $args[2]);
128 $try .= " );";
129 }
130 elsif ($f eq "blcm")
131 {
132 if (defined $args[2])
133 {
61f5c3f5 134 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01 135 }
136 $try .= "$class\::blcm(\$x, \$y";
137 $try .= ", \$z" if (defined $args[2]);
138 $try .= " );";
139 }elsif ($f eq "blsft"){
140 if (defined $args[2])
141 {
142 $try .= "\$x->blsft(\$y,$args[2]);";
143 }
144 else
145 {
146 $try .= "\$x << \$y;";
147 }
148 }elsif ($f eq "brsft"){
149 if (defined $args[2])
150 {
151 $try .= "\$x->brsft(\$y,$args[2]);";
152 }
153 else
154 {
155 $try .= "\$x >> \$y;";
156 }
990fb837 157 }elsif ($f eq "broot"){
158 $try .= "\$x->broot(\$y);";
6854fd01 159 }elsif ($f eq "band"){
160 $try .= "\$x & \$y;";
161 }elsif ($f eq "bior"){
162 $try .= "\$x | \$y;";
163 }elsif ($f eq "bxor"){
164 $try .= "\$x ^ \$y;";
165 }elsif ($f eq "bpow"){
166 $try .= "\$x ** \$y;";
d614cd8b 167 } elsif( $f eq "bmodinv") {
168 $try .= "\$x->bmodinv(\$y);";
6854fd01 169 }elsif ($f eq "digit"){
56b9c951 170 $try .= "\$x->digit(\$y);";
d614cd8b 171 } else {
172 $try .= "\$z = $class->new(\"$args[2]\");";
173
174 # Functions with three arguments
175 if( $f eq "bmodpow") {
176 $try .= "\$x->bmodpow(\$y,\$z);";
177 } else { warn "Unknown op '$f'"; }
178 }
61f5c3f5 179 } # end else all other ops
180
181 $ans1 = eval $try;
182 # convert hex/binary targets to decimal
183 if ($ans =~ /^(0x0x|0b0b)/)
184 {
185 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 186 }
61f5c3f5 187 if ($ans eq "")
188 {
189 ok_undef ($ans1);
190 }
191 else
192 {
193 # print "try: $try ans: $ans1 $ans\n";
194 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
b3abae2a 195 ok (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 196 }
61f5c3f5 197 # check internal state of number objects
198 is_valid($ans1,$f) if ref $ans1;
6854fd01 199 } # endwhile data tests
200close DATA;
201
202# test some more
203@a = ();
204for (my $i = 1; $i < 10; $i++)
205 {
206 push @a, $i;
207 }
208ok "@a", "1 2 3 4 5 6 7 8 9";
209
210# test whether self-multiplication works correctly (result is 2**64)
211$try = "\$x = $class->new('4294967296');";
212$try .= '$a = $x->bmul($x);';
213$ans1 = eval $try;
214print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
215# test self-pow
216$try = "\$x = $class->new(10);";
217$try .= '$a = $x->bpow($x);';
218$ans1 = eval $try;
219print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
220
07d34614 221###############################################################################
6854fd01 222# test whether op destroys args or not (should better not)
223
224$x = $class->new(3);
225$y = $class->new(4);
226$z = $x & $y;
227ok ($x,3);
228ok ($y,4);
229ok ($z,0);
230$z = $x | $y;
231ok ($x,3);
232ok ($y,4);
233ok ($z,7);
234$x = $class->new(1);
235$y = $class->new(2);
236$z = $x | $y;
237ok ($x,1);
238ok ($y,2);
239ok ($z,3);
240
241$x = $class->new(5);
242$y = $class->new(4);
243$z = $x ^ $y;
244ok ($x,5);
245ok ($y,4);
246ok ($z,1);
247
248$x = $class->new(-5); $y = -$x;
249ok ($x, -5);
250
251$x = $class->new(-5); $y = abs($x);
252ok ($x, -5);
253
07d34614 254$x = $class->new(8);
255$y = $class->new(-1);
256$z = $class->new(5033);
257my $u = $x->copy()->bmodpow($y,$z);
258ok ($u,4404);
259ok ($y,-1);
260ok ($z,5033);
261
262$x = $class->new(-5); $y = -$x; ok ($x,-5); ok ($y,5);
263$x = $class->new(-5); $y = $x->copy()->bneg(); ok ($x,-5); ok ($y,5);
264
265$x = $class->new(-5); $y = $class->new(3); $x->bmul($y); ok ($x,-15); ok ($y,3);
266$x = $class->new(-5); $y = $class->new(3); $x->badd($y); ok ($x,-2); ok ($y,3);
267$x = $class->new(-5); $y = $class->new(3); $x->bsub($y); ok ($x,-8); ok ($y,3);
268$x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); ok ($x,-5); ok ($y,3);
269$x = $class->new(-5); $y = $class->new(3); $x->bmod($y); ok ($x,1); ok ($y,3);
270
271$x = $class->new(5); $y = $class->new(3); $x->bmul($y); ok ($x,15); ok ($y,3);
272$x = $class->new(5); $y = $class->new(3); $x->badd($y); ok ($x,8); ok ($y,3);
273$x = $class->new(5); $y = $class->new(3); $x->bsub($y); ok ($x,2); ok ($y,3);
274$x = $class->new(15); $y = $class->new(3); $x->bdiv($y); ok ($x,5); ok ($y,3);
275$x = $class->new(5); $y = $class->new(3); $x->bmod($y); ok ($x,2); ok ($y,3);
276
277$x = $class->new(5); $y = $class->new(-3); $x->bmul($y); ok ($x,-15); ok($y,-3);
278$x = $class->new(5); $y = $class->new(-3); $x->badd($y); ok ($x,2); ok($y,-3);
279$x = $class->new(5); $y = $class->new(-3); $x->bsub($y); ok ($x,8); ok($y,-3);
280$x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); ok ($x,-5); ok($y,-3);
281$x = $class->new(5); $y = $class->new(-3); $x->bmod($y); ok ($x,-1); ok($y,-3);
282
283###############################################################################
6854fd01 284# check whether overloading cmp works
285$try = "\$x = $class->new(0);";
286$try .= "\$y = 10;";
287$try .= "'false' if \$x ne \$y;";
288$ans = eval $try;
289print "# For '$try'\n" if (!ok "$ans" , "false" );
290
291# we cant test for working cmpt with other objects here, we would need a dummy
292# object with stringify overload for this. see Math::String tests as example
293
294###############################################################################
6854fd01 295# check reversed order of arguments
027dc388 296
6854fd01 297$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
298$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
299print "# For '$try'\n" if (!ok "$ans" , "ok" );
300
301$try = "\$x = $class->new(10); \$x = 2 * \$x;";
302$try .= "'ok' if \$x == 20;"; $ans = eval $try;
303print "# For '$try'\n" if (!ok "$ans" , "ok" );
304
305$try = "\$x = $class->new(10); \$x = 2 + \$x;";
306$try .= "'ok' if \$x == 12;"; $ans = eval $try;
307print "# For '$try'\n" if (!ok "$ans" , "ok" );
308
309$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
310$try .= "'ok' if \$x == -8;"; $ans = eval $try;
311print "# For '$try'\n" if (!ok "$ans" , "ok" );
312
313$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
314$try .= "'ok' if \$x == 2;"; $ans = eval $try;
315print "# For '$try'\n" if (!ok "$ans" , "ok" );
316
027dc388 317$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
318$try .= "'ok' if \$x == 2;"; $ans = eval $try;
319print "# For '$try'\n" if (!ok "$ans" , "ok" );
320
321$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
322$try .= "'ok' if \$x == 4;"; $ans = eval $try;
323print "# For '$try'\n" if (!ok "$ans" , "ok" );
324
325$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
326$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
327print "# For '$try'\n" if (!ok "$ans" , "ok" );
328
329$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
330$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
331print "# For '$try'\n" if (!ok "$ans" , "ok" );
332
6854fd01 333###############################################################################
334# check badd(4,5) form
335
336$try = "\$x = $class\->badd(4,5);";
337$try .= "'ok' if \$x == 9;";
338$ans = eval $try;
339print "# For '$try'\n" if (!ok "$ans" , "ok" );
340
341###############################################################################
342# check undefs: NOT DONE YET
343
344###############################################################################
345# bool
346
f9a08e12 347$x = $class->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
348$x = $class->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
6854fd01 349
350###############################################################################
351# objectify()
352
353@args = Math::BigInt::objectify(2,4,5);
354ok (scalar @args,3); # $class, 4, 5
56b9c951 355ok ($args[0] =~ /^Math::BigInt/);
6854fd01 356ok ($args[1],4);
357ok ($args[2],5);
358
359@args = Math::BigInt::objectify(0,4,5);
360ok (scalar @args,3); # $class, 4, 5
56b9c951 361ok ($args[0] =~ /^Math::BigInt/);
6854fd01 362ok ($args[1],4);
363ok ($args[2],5);
364
365@args = Math::BigInt::objectify(2,4,5);
366ok (scalar @args,3); # $class, 4, 5
56b9c951 367ok ($args[0] =~ /^Math::BigInt/);
6854fd01 368ok ($args[1],4);
369ok ($args[2],5);
370
371@args = Math::BigInt::objectify(2,4,5,6,7);
372ok (scalar @args,5); # $class, 4, 5, 6, 7
56b9c951 373ok ($args[0] =~ /^Math::BigInt/);
6854fd01 374ok ($args[1],4); ok (ref($args[1]),$args[0]);
375ok ($args[2],5); ok (ref($args[2]),$args[0]);
376ok ($args[3],6); ok (ref($args[3]),'');
377ok ($args[4],7); ok (ref($args[4]),'');
378
379@args = Math::BigInt::objectify(2,$class,4,5,6,7);
380ok (scalar @args,5); # $class, 4, 5, 6, 7
381ok ($args[0],$class);
382ok ($args[1],4); ok (ref($args[1]),$args[0]);
383ok ($args[2],5); ok (ref($args[2]),$args[0]);
384ok ($args[3],6); ok (ref($args[3]),'');
385ok ($args[4],7); ok (ref($args[4]),'');
386
387###############################################################################
f9a08e12 388# test whether an opp calls objectify properly or not (or at least does what
389# it should do given non-objects, w/ or w/o objectify())
390
391ok ($class->new(123)->badd(123),246);
392ok ($class->badd(123,321),444);
393ok ($class->badd(123,$class->new(321)),444);
394
395ok ($class->new(123)->bsub(122),1);
396ok ($class->bsub(321,123),198);
397ok ($class->bsub(321,$class->new(123)),198);
398
399ok ($class->new(123)->bmul(123),15129);
400ok ($class->bmul(123,123),15129);
401ok ($class->bmul(123,$class->new(123)),15129);
402
403ok ($class->new(15129)->bdiv(123),123);
404ok ($class->bdiv(15129,123),123);
405ok ($class->bdiv(15129,$class->new(123)),123);
406
407ok ($class->new(15131)->bmod(123),2);
408ok ($class->bmod(15131,123),2);
409ok ($class->bmod(15131,$class->new(123)),2);
410
411ok ($class->new(2)->bpow(16),65536);
412ok ($class->bpow(2,16),65536);
413ok ($class->bpow(2,$class->new(16)),65536);
414
415ok ($class->new(2**15)->brsft(1),2**14);
416ok ($class->brsft(2**15,1),2**14);
417ok ($class->brsft(2**15,$class->new(1)),2**14);
418
419ok ($class->new(2**13)->blsft(1),2**14);
420ok ($class->blsft(2**13,1),2**14);
421ok ($class->blsft(2**13,$class->new(1)),2**14);
422
423###############################################################################
6854fd01 424# test for floating-point input (other tests in bnorm() below)
425
426$z = 1050000000000000; # may be int on systems with 64bit?
427$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
428$z = 1e+129; # definitely a float (may fail on UTS)
429# don't compare to $z, since some Perl versions stringify $z into something
430# like '1.e+129' or something equally ugly
431$x = $class->new($z); ok ($x->bsstr(),'1e+129');
432
433###############################################################################
56d9de68 434# test for whitespace inlcuding newlines to be handled correctly
435
436# ok ($Math::BigInt::strict,1); # the default
437
438foreach my $c (
439 qw/1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890/)
440 {
441 my $m = $class->new($c);
442 ok ($class->new("$c"),$m);
443 ok ($class->new(" $c"),$m);
444 ok ($class->new("$c "),$m);
445 ok ($class->new(" $c "),$m);
446 ok ($class->new("\n$c"),$m);
447 ok ($class->new("$c\n"),$m);
448 ok ($class->new("\n$c\n"),$m);
449 ok ($class->new(" \n$c\n"),$m);
450 ok ($class->new(" \n$c \n"),$m);
451 ok ($class->new(" \n$c\n "),$m);
452 ok ($class->new(" \n$c\n1"),'NaN');
453 ok ($class->new("1 \n$c\n1"),'NaN');
454 }
455
456###############################################################################
6854fd01 457# prime number tests, also test for **= and length()
458# found on: http://www.utm.edu/research/primes/notes/by_year.html
459
460# ((2^148)-1)/17
461$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
462ok ($x,"20988936657440586486151264256610222593863921");
463ok ($x->length(),length "20988936657440586486151264256610222593863921");
464
465# MM7 = 2^127-1
466$x = $class->new(2); $x **= 127; $x--;
467ok ($x,"170141183460469231731687303715884105727");
468
469$x = $class->new('215960156869840440586892398248');
470($x,$y) = $x->length();
471ok ($x,30); ok ($y,0);
472
473$x = $class->new('1_000_000_000_000');
474($x,$y) = $x->length();
475ok ($x,13); ok ($y,0);
476
477# I am afraid the following is not yet possible due to slowness
478# Also, testing for 2 meg output is a bit hard ;)
479#$x = $class->new(2); $x **= 6972593; $x--;
480
481# 593573509*2^332162+1 has exactly 1,000,000 digits
482# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
483#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
484#ok ($x->length(),1_000_000);
485
486###############################################################################
487# inheritance and overriding of _swap
488
489$x = Math::Foo->new(5);
490$x = $x - 8; # 8 - 5 instead of 5-8
491ok ($x,3);
492ok (ref($x),'Math::Foo');
493
494$x = Math::Foo->new(5);
495$x = 8 - $x; # 5 - 8 instead of 8 - 5
496ok ($x,-3);
497ok (ref($x),'Math::Foo');
498
499###############################################################################
500# Test whether +inf eq inf
501# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
502# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
503# like 1e100000 crash on some platforms. So simple test for the string 'inf'
504$x = $class->new('+inf'); ok ($x,'inf');
505
506###############################################################################
507###############################################################################
56d9de68 508# the followin tests only make sense with Math::BigInt::Calc or BareCalc or
509# FastCalc
6854fd01 510
56d9de68 511exit if $CALC !~ /^Math::BigInt::(|Bare|Fast)Calc$/; # for Pari et al.
6854fd01 512
513###############################################################################
514# check proper length of internal arrays
515
394e6ffb 516my $bl = $CL->_base_len();
6854fd01 517my $BASE = '9' x $bl;
518my $MAX = $BASE;
519$BASE++;
520
521$x = $class->new($MAX); is_valid($x); # f.i. 9999
522$x += 1; ok ($x,$BASE); is_valid($x); # 10000
523$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
524
525###############################################################################
526# check numify
527
528$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
529$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
61f5c3f5 530
531# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
532$x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
6854fd01 533$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
534$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
535ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
536
537###############################################################################
538# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
539
394e6ffb 540$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
541if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
542
543$x = $class->new($BASE+3); $x++;
544if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 545
394e6ffb 546# test for +0 instead of int():
547$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 548
549###############################################################################
56b9c951 550# test bug that $class->digit($string) did not work
551
552ok ($class->digit(123,2),1);
553
554###############################################################################
6854fd01 555# bug in sub where number with at least 6 trailing zeros after any op failed
556
394e6ffb 557$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 558ok ($z, 100000);
559ok ($x, 23456);
560
561###############################################################################
562# bug in shortcut in mul()
563
61f5c3f5 564# construct a number with a zero-hole of BASE_LEN_SMALL
565{
566 my @bl = $CL->_base_len(); my $bl = $bl[4];
567
568 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
569 $y = '1' x (2*$bl);
570 $x = $class->new($x)->bmul($y);
571 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
572 $y = ''; my $d = '';
573 for (my $i = 1; $i <= $bl; $i++)
574 {
575 $y .= $i; $d = $i.$d;
576 }
577 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
578 ok ($x,$y);
579
6854fd01 580
f9a08e12 581 #############################################################################
582 # see if mul shortcut for small numbers works
394e6ffb 583
f9a08e12 584 $x = '9' x $bl;
585 $x = $class->new($x);
586 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
587 ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
588}
61f5c3f5 589
394e6ffb 590###############################################################################
6854fd01 591# bug with rest "-0" in div, causing further div()s to fail
592
394e6ffb 593$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 594
61f5c3f5 595ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 596
79c55733 597###############################################################################
f9a08e12 598# bug in $x->bmod($y)
07d34614 599
f9a08e12 600# if $x < 0 and $y > 0
07d34614 601$x = $class->new('-629'); ok ($x->bmod(5033),4404);
602
603###############################################################################
56b9c951 604# bone/binf etc as plain calls (Lite failed them)
605
606ok ($class->bzero(),0);
607ok ($class->bone(),1);
608ok ($class->bone('+'),1);
609ok ($class->bone('-'),-1);
610ok ($class->bnan(),'NaN');
611ok ($class->binf(),'inf');
612ok ($class->binf('+'),'inf');
613ok ($class->binf('-'),'-inf');
614ok ($class->binf('-inf'),'-inf');
615
616###############################################################################
990fb837 617# is_one('-')
618
619ok ($class->new(1)->is_one('-'),0);
620ok ($class->new(-1)->is_one('-'),1);
621ok ($class->new(1)->is_one(),1);
622ok ($class->new(-1)->is_one(),0);
623
624###############################################################################
61f5c3f5 625# all tests done
6854fd01 626
6271;
628
629###############################################################################
61f5c3f5 630###############################################################################
6854fd01 631# Perl 5.005 does not like ok ($x,undef)
632
633sub ok_undef
634 {
635 my $x = shift;
636
637 ok (1,1) and return if !defined $x;
638 ok ($x,'undef');
639 }
640
641###############################################################################
642# sub to check validity of a BigInt internally, to ensure that no op leaves a
643# number object in an invalid state (f.i. "-0")
644
645sub is_valid
646 {
647 my ($x,$f) = @_;
648
649 my $e = 0; # error?
6854fd01 650
56b9c951 651 # allow the check to pass for all Lite, and all MBI and subclasses
652 # ok as reference?
653 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 654
56b9c951 655 if (ref($x) ne 'Math::BigInt::Lite')
656 {
657 # has ok sign?
658 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
659 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
660
661 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
662 $e = $CALC->_check($x->{value}) if $e eq '0';
663 }
6854fd01 664
665 # test done, see if error did crop up
666 ok (1,1), return if ($e eq '0');
667
027dc388 668 ok (1,$e." after op '$f'");
6854fd01 669 }
670
671__DATA__
027dc388 672&.=
6731234:-345:1234-345
674&+=
6751:2:3
676-1:-2:-3
677&-=
6781:2:-1
679-1:-2:1
680&*=
6812:3:6
682-1:5:-5
683&%=
684100:3:1
6858:9:8
07d34614 686-629:5033:4404
027dc388 687&/=
688100:3:33
689-8:2:-4
690&|=
6912:1:3
692&&=
6935:7:5
694&^=
6955:7:2
6854fd01 696&is_negative
6970:0
698-1:1
6991:0
700+inf:0
701-inf:1
702NaNneg:0
703&is_positive
7040:1
705-1:0
7061:1
707+inf:1
708-inf:0
709NaNneg:0
b3abae2a 710&is_int
711-inf:0
712+inf:0
713NaNis_int:0
7141:1
7150:1
716123e12:1
6854fd01 717&is_odd
718abc:0
7190:0
7201:1
7213:1
722-1:1
723-3:1
72410000001:1
72510000002:0
7262:0
b3abae2a 727120:0
728121:1
6854fd01 729&is_even
730abc:0
7310:1
7321:0
7333:0
734-1:0
735-3:0
73610000001:0
73710000002:1
7382:1
b3abae2a 739120:1
740121:0
6854fd01 741&bacmp
742+0:-0:0
743+0:+1:-1
744-1:+1:0
745+1:-1:0
746-1:+2:-1
747+2:-1:1
748-123456789:+987654321:-1
749+123456789:-987654321:-1
750+987654321:+123456789:1
751-987654321:+123456789:1
752-123:+4567889:-1
753# NaNs
754acmpNaN:123:
755123:acmpNaN:
756acmpNaN:acmpNaN:
757# infinity
758+inf:+inf:0
759-inf:-inf:0
760+inf:-inf:0
761-inf:+inf:0
762+inf:123:1
763-inf:123:1
764+inf:-123:1
765-inf:-123:1
766# return undef
767+inf:NaN:
768NaN:inf:
769-inf:NaN:
770NaN:-inf:
771&bnorm
aef458a0 7720e999:0
7730e-999:0
774-0e999:0
775-0e-999:0
6854fd01 776123:123
777# binary input
7780babc:NaN
7790b123:NaN
7800b0:0
781-0b0:0
782-0b1:-1
7830b0001:1
7840b001:1
7850b011:3
7860b101:5
61f5c3f5 7870b1001:9
7880b10001:17
7890b100001:33
7900b1000001:65
7910b10000001:129
7920b100000001:257
7930b1000000001:513
7940b10000000001:1025
7950b100000000001:2049
7960b1000000000001:4097
7970b10000000000001:8193
7980b100000000000001:16385
7990b1000000000000001:32769
8000b10000000000000001:65537
8010b100000000000000001:131073
8020b1000000000000000001:262145
8030b10000000000000000001:524289
8040b100000000000000000001:1048577
8050b1000000000000000000001:2097153
8060b10000000000000000000001:4194305
8070b100000000000000000000001:8388609
8080b1000000000000000000000001:16777217
8090b10000000000000000000000001:33554433
8100b100000000000000000000000001:67108865
8110b1000000000000000000000000001:134217729
8120b10000000000000000000000000001:268435457
8130b100000000000000000000000000001:536870913
8140b1000000000000000000000000000001:1073741825
8150b10000000000000000000000000000001:2147483649
8160b100000000000000000000000000000001:4294967297
8170b1000000000000000000000000000000001:8589934593
8180b10000000000000000000000000000000001:17179869185
6854fd01 8190b_101:NaN
8200b1_0_1:5
394e6ffb 8210b0_0_0_1:1
6854fd01 822# hex input
823-0x0:0
8240xabcdefgh:NaN
8250x1234:4660
8260xabcdef:11259375
827-0xABCDEF:-11259375
828-0x1234:-4660
8290x12345678:305419896
8300x1_2_3_4_56_78:305419896
394e6ffb 8310xa_b_c_d_e_f:11259375
6854fd01 8320x_123:NaN
61f5c3f5 8330x9:9
8340x11:17
8350x21:33
8360x41:65
8370x81:129
8380x101:257
8390x201:513
8400x401:1025
8410x801:2049
8420x1001:4097
8430x2001:8193
8440x4001:16385
8450x8001:32769
8460x10001:65537
8470x20001:131073
8480x40001:262145
8490x80001:524289
8500x100001:1048577
8510x200001:2097153
8520x400001:4194305
8530x800001:8388609
8540x1000001:16777217
8550x2000001:33554433
8560x4000001:67108865
8570x8000001:134217729
8580x10000001:268435457
8590x20000001:536870913
8600x40000001:1073741825
8610x80000001:2147483649
8620x100000001:4294967297
8630x200000001:8589934593
8640x400000001:17179869185
8650x800000001:34359738369
6854fd01 866# inf input
867inf:inf
868+inf:inf
869-inf:-inf
8700inf:NaN
027dc388 871# abnormal input
6854fd01 872:NaN
873abc:NaN
874 1 a:NaN
8751bcd2:NaN
87611111b:NaN
877+1z:NaN
878-1z:NaN
027dc388 879# only one underscore between two digits
880_123:NaN
881_123_:NaN
882123_:NaN
8831__23:NaN
8841E1__2:NaN
8851_E12:NaN
8861E_12:NaN
8871_E_12:NaN
888+_1E12:NaN
889+0_1E2:100
890+0_0_1E2:100
891-0_0_1E2:-100
892-0_0_1E+0_0_2:-100
893E1:NaN
894E23:NaN
8951.23E1:NaN
8961.23E-1:NaN
897# bug with two E's in number beeing valid
8981e2e3:NaN
8991e2r:NaN
9001e2.0:NaN
07d34614 901# bug with two '.' in number beeing valid
9021.2.2:NaN
9031.2.3e1:NaN
904-1.2.3:NaN
905-1.2.3e-4:NaN
9061.2e3.4:NaN
9071.2e-3.4:NaN
9081.2.3.4:NaN
9091.2.t:NaN
9101..2:NaN
9111..2e1:NaN
9121..2e1..1:NaN
91312e1..1:NaN
914..2:NaN
915.-2:NaN
61f5c3f5 916# leading zeros
917012:12
9180123:123
91901234:1234
920012345:12345
9210123456:123456
92201234567:1234567
923012345678:12345678
9240123456789:123456789
92501234567891:1234567891
926012345678912:12345678912
9270123456789123:123456789123
92801234567891234:1234567891234
027dc388 929# normal input
6854fd01 9300:0
931+0:0
932+00:0
933+000:0
934000000000000000000:0
935-0:0
936-0000:0
937+1:1
938+01:1
939+001:1
940+00000100000:100000
941123456789:123456789
942-1:-1
943-01:-1
944-001:-1
945-123456789:-123456789
946-00000100000:-100000
9471_2_3:123
6854fd01 94810000000000E-1_0:1
9491E2:100
9501E1:10
9511E0:1
6854fd01 9521.23E2:123
6854fd01 953100E-1:10
954# floating point input
027dc388 955# .2e2:20
9561.E3:1000
6854fd01 9571.01E2:101
9581010E-1:101
959-1010E0:-1010
960-1010E1:-10100
027dc388 9611234.00:1234
962# non-integer numbers
6854fd01 963-1010E-2:NaN
964-1.01E+1:NaN
965-1.01E-1:NaN
6854fd01 966&bnan
9671:NaN
9682:NaN
969abc:NaN
970&bone
61f5c3f5 9712:+:1
6854fd01 9722:-:-1
973boneNaN:-:-1
61f5c3f5 974boneNaN:+:1
9752:abc:1
9763::1
6854fd01 977&binf
9781:+:inf
9792:-:-inf
9803:abc:inf
027dc388 981&is_nan
982123:0
983abc:1
984NaN:1
985-123:0
6854fd01 986&is_inf
987+inf::1
988-inf::1
989abc::0
9901::0
991NaN::0
992-1::0
993+inf:-:0
994+inf:+:1
995-inf:-:1
996-inf:+:0
79c55733 997-inf:-inf:1
998-inf:+inf:0
999+inf:-inf:0
1000+inf:+inf:1
6854fd01 1001# it must be exactly /^[+-]inf$/
1002+infinity::0
1003-infinity::0
1004&blsft
1005abc:abc:NaN
61f5c3f5 1006+2:+2:8
1007+1:+32:4294967296
1008+1:+48:281474976710656
6854fd01 1009+8:-2:NaN
1010# excercise base 10
1011+12345:4:10:123450000
1012-1234:0:10:-1234
61f5c3f5 1013+1234:0:10:1234
6854fd01 1014+2:2:10:200
1015+12:2:10:1200
1016+1234:-3:10:NaN
10171234567890123:12:10:1234567890123000000000000
b3abae2a 1018-3:1:2:-6
1019-5:1:2:-10
1020-2:1:2:-4
1021-102533203:1:2:-205066406
6854fd01 1022&brsft
1023abc:abc:NaN
61f5c3f5 1024+8:+2:2
1025+4294967296:+32:1
1026+281474976710656:+48:1
6854fd01 1027+2:-2:NaN
1028# excercise base 10
1029-1234:0:10:-1234
61f5c3f5 1030+1234:0:10:1234
6854fd01 1031+200:2:10:2
1032+1234:3:10:1
1033+1234:2:10:12
1034+1234:-3:10:NaN
1035310000:4:10:31
103612300000:5:10:123
10371230000000000:10:10:123
103809876123456789067890:12:10:9876123
10391234561234567890123:13:10:123456
b3abae2a 1040820265627:1:2:410132813
1041# test shifting negative numbers in base 2
1042-15:1:2:-8
1043-14:1:2:-7
1044-13:1:2:-7
1045-12:1:2:-6
1046-11:1:2:-6
1047-10:1:2:-5
1048-9:1:2:-5
1049-8:1:2:-4
1050-7:1:2:-4
1051-6:1:2:-3
1052-5:1:2:-3
1053-4:1:2:-2
1054-3:1:2:-2
1055-2:1:2:-1
1056-1:1:2:-1
1057-1640531254:2:2:-410132814
1058-1640531254:1:2:-820265627
1059-820265627:1:2:-410132814
1060-205066405:1:2:-102533203
6854fd01 1061&bsstr
56d9de68 1062+inf:inf
1063-inf:-inf
6854fd01 10641e+34:1e+34
1065123.456E3:123456e+0
1066100:1e+2
56d9de68 1067bsstrabc:NaN
1068-5:-5e+0
1069-100:-1e+2
1070&numify
1071numifyabc:NaN
1072+inf:inf
1073-inf:-inf
10745:5
1075-5:-5
1076100:100
1077-100:-100
6854fd01 1078&bneg
1079bnegNaN:NaN
1080+inf:-inf
1081-inf:inf
1082abd:NaN
61f5c3f5 10830:0
10841:-1
1085-1:1
6854fd01 1086+123456789:-123456789
61f5c3f5 1087-123456789:123456789
6854fd01 1088&babs
1089babsNaN:NaN
1090+inf:inf
1091-inf:inf
61f5c3f5 10920:0
10931:1
1094-1:1
1095+123456789:123456789
1096-123456789:123456789
6854fd01 1097&bcmp
1098bcmpNaN:bcmpNaN:
61f5c3f5 1099bcmpNaN:0:
11000:bcmpNaN:
11010:0:0
1102-1:0:-1
11030:-1:1
11041:0:1
11050:1:-1
1106-1:1:-1
11071:-1:1
6854fd01 1108-1:-1:0
61f5c3f5 11091:1:0
1110123:123:0
1111123:12:1
111212:123:-1
6854fd01 1113-123:-123:0
1114-123:-12:-1
1115-12:-123:1
61f5c3f5 1116123:124:-1
1117124:123:1
6854fd01 1118-123:-124:1
1119-124:-123:-1
61f5c3f5 1120100:5:1
1121-123456789:987654321:-1
6854fd01 1122+123456789:-987654321:1
61f5c3f5 1123-987654321:123456789:-1
6854fd01 1124-inf:5432112345:-1
1125+inf:5432112345:1
1126-inf:-5432112345:-1
1127+inf:-5432112345:1
1128+inf:+inf:0
1129-inf:-inf:0
1130+inf:-inf:1
1131-inf:+inf:-1
11325:inf:-1
11335:inf:-1
1134-5:-inf:1
1135-5:-inf:1
1136# return undef
1137+inf:NaN:
1138NaN:inf:
1139-inf:NaN:
1140NaN:-inf:
1141&binc
1142abc:NaN
1143+inf:inf
1144-inf:-inf
61f5c3f5 1145+0:1
1146+1:2
1147-1:0
6854fd01 1148&bdec
1149abc:NaN
1150+inf:inf
1151-inf:-inf
1152+0:-1
61f5c3f5 1153+1:0
6854fd01 1154-1:-2
1155&badd
1156abc:abc:NaN
61f5c3f5 1157abc:0:NaN
6854fd01 1158+0:abc:NaN
b3abae2a 1159+inf:-inf:NaN
1160-inf:+inf:NaN
6854fd01 1161+inf:+inf:inf
1162-inf:-inf:-inf
1163baddNaN:+inf:NaN
1164baddNaN:+inf:NaN
1165+inf:baddNaN:NaN
1166-inf:baddNaN:NaN
61f5c3f5 11670:0:0
11681:0:1
11690:1:1
11701:1:2
1171-1:0:-1
11720:-1:-1
6854fd01 1173-1:-1:-2
61f5c3f5 1174-1:+1:0
1175+1:-1:0
1176+9:+1:10
1177+99:+1:100
1178+999:+1:1000
1179+9999:+1:10000
1180+99999:+1:100000
1181+999999:+1:1000000
1182+9999999:+1:10000000
1183+99999999:+1:100000000
1184+999999999:+1:1000000000
1185+9999999999:+1:10000000000
1186+99999999999:+1:100000000000
1187+10:-1:9
1188+100:-1:99
1189+1000:-1:999
1190+10000:-1:9999
1191+100000:-1:99999
1192+1000000:-1:999999
1193+10000000:-1:9999999
1194+100000000:-1:99999999
1195+1000000000:-1:999999999
1196+10000000000:-1:9999999999
1197+123456789:987654321:1111111110
1198-123456789:987654321:864197532
6854fd01 1199-123456789:-987654321:-1111111110
1200+123456789:-987654321:-864197532
56b9c951 1201-1:10001:10000
1202-1:100001:100000
1203-1:1000001:1000000
1204-1:10000001:10000000
1205-1:100000001:100000000
1206-1:1000000001:1000000000
1207-1:10000000001:10000000000
1208-1:100000000001:100000000000
1209-1:1000000000001:1000000000000
1210-1:10000000000001:10000000000000
1211-1:-10001:-10002
1212-1:-100001:-100002
1213-1:-1000001:-1000002
1214-1:-10000001:-10000002
1215-1:-100000001:-100000002
1216-1:-1000000001:-1000000002
1217-1:-10000000001:-10000000002
1218-1:-100000000001:-100000000002
1219-1:-1000000000001:-1000000000002
1220-1:-10000000000001:-10000000000002
6854fd01 1221&bsub
1222abc:abc:NaN
1223abc:+0:NaN
1224+0:abc:NaN
1225+inf:-inf:inf
1226-inf:+inf:-inf
b3abae2a 1227+inf:+inf:NaN
1228-inf:-inf:NaN
61f5c3f5 1229+0:+0:0
1230+1:+0:1
6854fd01 1231+0:+1:-1
61f5c3f5 1232+1:+1:0
6854fd01 1233-1:+0:-1
61f5c3f5 1234+0:-1:1
1235-1:-1:0
6854fd01 1236-1:+1:-2
61f5c3f5 1237+1:-1:2
1238+9:+1:8
1239+99:+1:98
1240+999:+1:998
1241+9999:+1:9998
1242+99999:+1:99998
1243+999999:+1:999998
1244+9999999:+1:9999998
1245+99999999:+1:99999998
1246+999999999:+1:999999998
1247+9999999999:+1:9999999998
1248+99999999999:+1:99999999998
1249+10:-1:11
1250+100:-1:101
1251+1000:-1:1001
1252+10000:-1:10001
1253+100000:-1:100001
1254+1000000:-1:1000001
1255+10000000:-1:10000001
1256+100000000:-1:100000001
1257+1000000000:-1:1000000001
1258+10000000000:-1:10000000001
6854fd01 1259+123456789:+987654321:-864197532
1260-123456789:+987654321:-1111111110
61f5c3f5 1261-123456789:-987654321:864197532
1262+123456789:-987654321:1111111110
56b9c951 126310001:1:10000
1264100001:1:100000
12651000001:1:1000000
126610000001:1:10000000
1267100000001:1:100000000
12681000000001:1:1000000000
126910000000001:1:10000000000
1270100000000001:1:100000000000
12711000000000001:1:1000000000000
127210000000000001:1:10000000000000
127310001:-1:10002
1274100001:-1:100002
12751000001:-1:1000002
127610000001:-1:10000002
1277100000001:-1:100000002
12781000000001:-1:1000000002
127910000000001:-1:10000000002
1280100000000001:-1:100000000002
12811000000000001:-1:1000000000002
128210000000000001:-1:10000000000002
6854fd01 1283&bmul
1284abc:abc:NaN
1285abc:+0:NaN
1286+0:abc:NaN
1287NaNmul:+inf:NaN
1288NaNmul:-inf:NaN
1289-inf:NaNmul:NaN
1290+inf:NaNmul:NaN
1291+inf:+inf:inf
1292+inf:-inf:-inf
1293-inf:+inf:-inf
1294-inf:-inf:inf
61f5c3f5 1295+0:+0:0
1296+0:+1:0
1297+1:+0:0
1298+0:-1:0
1299-1:+0:0
1300123456789123456789:0:0
13010:123456789123456789:0
1302-1:-1:1
6854fd01 1303-1:+1:-1
1304+1:-1:-1
61f5c3f5 1305+1:+1:1
1306+2:+3:6
6854fd01 1307-2:+3:-6
1308+2:-3:-6
61f5c3f5 1309-2:-3:6
1310111:111:12321
131110101:10101:102030201
13121001001:1001001:1002003002001
1313100010001:100010001:10002000300020001
131410000100001:10000100001:100002000030000200001
131511111111111:9:99999999999
131622222222222:9:199999999998
131733333333333:9:299999999997
131844444444444:9:399999999996
131955555555555:9:499999999995
132066666666666:9:599999999994
132177777777777:9:699999999993
132288888888888:9:799999999992
132399999999999:9:899999999991
1324+25:+25:625
1325+12345:+12345:152399025
1326+99999:+11111:1111088889
6854fd01 13279999:10000:99990000
132899999:100000:9999900000
1329999999:1000000:999999000000
13309999999:10000000:99999990000000
133199999999:100000000:9999999900000000
1332999999999:1000000000:999999999000000000
13339999999999:10000000000:99999999990000000000
133499999999999:100000000000:9999999999900000000000
1335999999999999:1000000000000:999999999999000000000000
13369999999999999:10000000000000:99999999999990000000000000
133799999999999999:100000000000000:9999999999999900000000000000
1338999999999999999:1000000000000000:999999999999999000000000000000
13399999999999999999:10000000000000000:99999999999999990000000000000000
134099999999999999999:100000000000000000:9999999999999999900000000000000000
1341999999999999999999:1000000000000000000:999999999999999999000000000000000000
13429999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1343&bdiv-list
1344100:20:5,0
13454095:4095:1,0
1346-4095:-4095:1,0
13474095:-4095:-1,0
1348-4095:4095:-1,0
1349123:2:61,1
b3abae2a 13509:5:1,4
13519:4:2,1
6854fd01 1352# inf handling and general remainder
13535:8:0,5
13540:8:0,0
135511:2:5,1
135611:-2:-5,-1
1357-11:2:-5,1
1358# see table in documentation in MBI
13590:inf:0,0
13600:-inf:0,0
13615:inf:0,5
13625:-inf:0,5
1363-5:inf:0,-5
1364-5:-inf:0,-5
1365inf:5:inf,0
1366-inf:5:-inf,0
1367inf:-5:-inf,0
1368-inf:-5:inf,0
13695:5:1,0
1370-5:-5:1,0
b3abae2a 1371inf:inf:NaN,NaN
1372-inf:-inf:NaN,NaN
1373-inf:inf:NaN,NaN
1374inf:-inf:NaN,NaN
6854fd01 13758:0:inf,8
1376inf:0:inf,inf
1377# exceptions to reminder rule
1378-8:0:-inf,-8
1379-inf:0:-inf,-inf
13800:0:NaN,NaN
990fb837 1381# test the shortcut in Calc if @$x == @$yorg
13821234567812345678:123456712345678:10,688888898
138312345671234567:1234561234567:10,58888897
1384123456123456:12345123456:10,4888896
13851234512345:123412345:10,388895
13861234567890999999999:1234567890:1000000000,999999999
13871234567890000000000:1234567890:1000000000,0
13881234567890999999999:9876543210:124999998,9503086419
13891234567890000000000:9876543210:124999998,8503086420
139096969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
6854fd01 1391&bdiv
1392abc:abc:NaN
61f5c3f5 1393abc:1:NaN
13941:abc:NaN
13950:0:NaN
6854fd01 1396# inf handling (see table in doc)
13970:inf:0
13980:-inf:0
13995:inf:0
14005:-inf:0
1401-5:inf:0
1402-5:-inf:0
1403inf:5:inf
1404-inf:5:-inf
1405inf:-5:-inf
1406-inf:-5:inf
14075:5:1
1408-5:-5:1
b3abae2a 1409inf:inf:NaN
1410-inf:-inf:NaN
1411-inf:inf:NaN
1412inf:-inf:NaN
6854fd01 14138:0:inf
1414inf:0:inf
1415-8:0:-inf
1416-inf:0:-inf
14170:0:NaN
141811:2:5
1419-11:-2:5
1420-11:2:-5
142111:-2:-5
61f5c3f5 14220:1:0
14230:-1:0
14241:1:1
1425-1:-1:1
14261:-1:-1
1427-1:1:-1
14281:2:0
14292:1:2
14301:26:0
14311000000000:9:111111111
14322000000000:9:222222222
14333000000000:9:333333333
14344000000000:9:444444444
14355000000000:9:555555555
14366000000000:9:666666666
14377000000000:9:777777777
14388000000000:9:888888888
14399000000000:9:1000000000
144035500000:113:314159
144171000000:226:314159
1442106500000:339:314159
14431000000000:3:333333333
1444+10:+5:2
1445+100:+4:25
1446+1000:+8:125
1447+10000:+16:625
1448999999999999:9:111111111111
1449999999999999:99:10101010101
1450999999999999:999:1001001001
1451999999999999:9999:100010001
1452999999999999999:99999:10000100001
1453+1111088889:99999:11111
6854fd01 1454-5:-3:1
1455-5:3:-1
14564:3:1
14574:-3:-1
14581:3:0
14591:-3:0
1460-2:-3:0
1461-2:3:0
14628:3:2
1463-8:3:-2
146414:-3:-4
1465-14:3:-4
1466-14:-3:4
146714:3:4
1468# bug in Calc with '99999' vs $BASE-1
146910000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
990fb837 1470# test the shortcut in Calc if @$x == @$yorg
14711234567812345678:123456712345678:10
147212345671234567:1234561234567:10
1473123456123456:12345123456:10
14741234512345:123412345:10
14751234567890999999999:1234567890:1000000000
14761234567890000000000:1234567890:1000000000
14771234567890999999999:9876543210:124999998
14781234567890000000000:9876543210:124999998
147996969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
aef458a0 1480# bug up to v0.35 in Calc (--$q one too many)
148184696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
148284696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
148384696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
148484696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
07d34614 1485&bmodinv
1486# format: number:modulus:result
1487# bmodinv Data errors
1488abc:abc:NaN
1489abc:5:NaN
14905:abc:NaN
1491# bmodinv Expected Results from normal use
14921:5:1
14933:5:2
1494-2:5:2
14958:5033:4404
56d9de68 14961234567891:13:6
1497-1234567891:13:7
07d34614 1498324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
d614cd8b 1499## bmodinv Error cases / useless use of function
07d34614 15003:-5:NaN
1501inf:5:NaN
1ddff52a 15025:inf:NaN
1503-inf:5:NaN
15045:-inf:NaN
07d34614 1505&bmodpow
1506# format: number:exponent:modulus:result
1507# bmodpow Data errors
1508abc:abc:abc:NaN
15095:abc:abc:NaN
1510abc:5:abc:NaN
1511abc:abc:5:NaN
15125:5:abc:NaN
15135:abc:5:NaN
1514abc:5:5:NaN
1515# bmodpow Expected results
15160:0:2:1
15171:0:2:1
15180:0:1:0
15198:7:5032:3840
15208:-1:5033:4404
152198436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1522# bmodpow Error cases
15238:8:-5:NaN
15248:-1:16:NaN
1525inf:5:13:NaN
15265:inf:13:NaN
6854fd01 1527&bmod
1528# inf handling, see table in doc
15290:inf:0
15300:-inf:0
15315:inf:5
15325:-inf:5
1533-5:inf:-5
1534-5:-inf:-5
1535inf:5:0
1536-inf:5:0
1537inf:-5:0
1538-inf:-5:0
15395:5:0
1540-5:-5:0
b3abae2a 1541inf:inf:NaN
1542-inf:-inf:NaN
1543-inf:inf:NaN
1544inf:-inf:NaN
6854fd01 15458:0:8
1546inf:0:inf
1547# exceptions to reminder rule
1548-inf:0:-inf
1549-8:0:-8
15500:0:NaN
1551abc:abc:NaN
61f5c3f5 1552abc:1:abc:NaN
15531:abc:NaN
15540:0:NaN
15550:1:0
15561:0:1
15570:-1:0
1558-1:0:-1
15591:1:0
1560-1:-1:0
15611:-1:0
1562-1:1:0
15631:2:1
15642:1:0
15651000000000:9:1
15662000000000:9:2
15673000000000:9:3
15684000000000:9:4
15695000000000:9:5
15706000000000:9:6
15717000000000:9:7
15728000000000:9:8
15739000000000:9:0
157435500000:113:33
157571000000:226:66
1576106500000:339:99
15771000000000:3:1
157810:5:0
1579100:4:0
15801000:8:0
158110000:16:0
1582999999999999:9:0
1583999999999999:99:0
1584999999999999:999:0
1585999999999999:9999:0
1586999999999999999:99999:0
1587-9:+5:1
6854fd01 1588+9:-5:-1
1589-9:-5:-4
1590-5:3:1
1591-2:3:1
15924:3:1
15931:3:1
1594-5:-3:-2
1595-2:-3:-2
15964:-3:-2
15971:-3:-2
15984095:4095:0
027dc388 1599100041000510123:3:0
1600152403346:12345:4321
b3abae2a 16019:5:4
28df3e88 1602# test shortcuts in Calc
1603# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
16041234:9:1
1605123456:9:3
160612345678:9:0
16071234567891:9:1
1608123456789123:9:6
160912345678912345:9:6
16101234567891234567:9:1
1611123456789123456789:9:0
16121234:10:4
1613123456:10:6
161412345678:10:8
16151234567891:10:1
1616123456789123:10:3
161712345678912345:10:5
16181234567891234567:10:7
1619123456789123456789:10:9
16201234:113:104
1621123456:113:60
162212345678:113:89
16231234567891:113:64
1624123456789123:113:95
162512345678912345:113:53
16261234567891234567:113:56
1627123456789123456789:113:39
07d34614 1628# bug in bmod() not modifying the variable in place
1629-629:5033:4404
aef458a0 1630# bug in bmod() in Calc in the _div_use_div() shortcut code path,
1631# when X == X and X was big
1632111111111111111111111111111111:111111111111111111111111111111:0
163312345678901234567890:12345678901234567890:0
6854fd01 1634&bgcd
1635abc:abc:NaN
1636abc:+0:NaN
1637+0:abc:NaN
61f5c3f5 1638+0:+0:0
1639+0:+1:1
1640+1:+0:1
1641+1:+1:1
1642+2:+3:1
1643+3:+2:1
1644-3:+2:1
1645100:625:25
16464096:81:1
16471034:804:2
164827:90:56:1
164927:90:54:9
6854fd01 1650&blcm
1651abc:abc:NaN
1652abc:+0:NaN
1653+0:abc:NaN
1654+0:+0:NaN
61f5c3f5 1655+1:+0:0
1656+0:+1:0
1657+27:+90:270
1658+1034:+804:415668
6854fd01 1659&band
1660abc:abc:NaN
1661abc:0:NaN
16620:abc:NaN
16631:2:0
16643:2:2
61f5c3f5 1665+8:+2:0
1666+281474976710656:0:0
1667+281474976710656:1:0
1668+281474976710656:+281474976710656:281474976710656
6854fd01 1669-2:-3:-4
1670-1:-1:-1
1671-6:-6:-6
1672-7:-4:-8
1673-7:4:0
1674-4:7:4
394e6ffb 1675# equal arguments are treated special, so also do some test with unequal ones
16760xFFFF:0xFFFF:0x0xFFFF
16770xFFFFFF:0xFFFFFF:0x0xFFFFFF
16780xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
16790xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
16800xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
16810xF0F0:0xF0F0:0x0xF0F0
16820x0F0F:0x0F0F:0x0x0F0F
16830xF0F0F0:0xF0F0F0:0x0xF0F0F0
16840x0F0F0F:0x0F0F0F:0x0x0F0F0F
16850xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
16860x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
16870xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
16880x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
16890xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
16900x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
16910x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1692&bior
1693abc:abc:NaN
1694abc:0:NaN
16950:abc:NaN
16961:2:3
61f5c3f5 1697+8:+2:10
1698+281474976710656:0:281474976710656
1699+281474976710656:1:281474976710657
1700+281474976710656:281474976710656:281474976710656
6854fd01 1701-2:-3:-1
1702-1:-1:-1
1703-6:-6:-6
1704-7:4:-3
1705-4:7:-1
394e6ffb 1706# equal arguments are treated special, so also do some test with unequal ones
17070xFFFF:0xFFFF:0x0xFFFF
17080xFFFFFF:0xFFFFFF:0x0xFFFFFF
17090xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
17100xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17110xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17120:0xFFFF:0x0xFFFF
17130:0xFFFFFF:0x0xFFFFFF
17140:0xFFFFFFFF:0x0xFFFFFFFF
17150:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17160:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17170xFFFF:0:0x0xFFFF
17180xFFFFFF:0:0x0xFFFFFF
17190xFFFFFFFF:0:0x0xFFFFFFFF
17200xFFFFFFFFFF:0:0x0xFFFFFFFFFF
17210xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
17220xF0F0:0xF0F0:0x0xF0F0
17230x0F0F:0x0F0F:0x0x0F0F
17240xF0F0:0x0F0F:0x0xFFFF
17250xF0F0F0:0xF0F0F0:0x0xF0F0F0
17260x0F0F0F:0x0F0F0F:0x0x0F0F0F
17270x0F0F0F:0xF0F0F0:0x0xFFFFFF
17280xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
17290x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
17300x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
17310xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
17320x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
17330x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
17340xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
17350x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
17360x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
17370x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1738&bxor
1739abc:abc:NaN
1740abc:0:NaN
17410:abc:NaN
17421:2:3
61f5c3f5 1743+8:+2:10
1744+281474976710656:0:281474976710656
1745+281474976710656:1:281474976710657
1746+281474976710656:281474976710656:0
6854fd01 1747-2:-3:3
1748-1:-1:0
1749-6:-6:0
1750-7:4:-3
1751-4:7:-5
17524:-7:-3
1753-4:-7:5
394e6ffb 1754# equal arguments are treated special, so also do some test with unequal ones
17550xFFFF:0xFFFF:0
17560xFFFFFF:0xFFFFFF:0
17570xFFFFFFFF:0xFFFFFFFF:0
17580xFFFFFFFFFF:0xFFFFFFFFFF:0
17590xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
17600:0xFFFF:0x0xFFFF
17610:0xFFFFFF:0x0xFFFFFF
17620:0xFFFFFFFF:0x0xFFFFFFFF
17630:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17640:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17650xFFFF:0:0x0xFFFF
17660xFFFFFF:0:0x0xFFFFFF
17670xFFFFFFFF:0:0x0xFFFFFFFF
17680xFFFFFFFFFF:0:0x0xFFFFFFFFFF
17690xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
17700xF0F0:0xF0F0:0
17710x0F0F:0x0F0F:0
17720xF0F0:0x0F0F:0x0xFFFF
17730xF0F0F0:0xF0F0F0:0
17740x0F0F0F:0x0F0F0F:0
17750x0F0F0F:0xF0F0F0:0x0xFFFFFF
17760xF0F0F0F0:0xF0F0F0F0:0
17770x0F0F0F0F:0x0F0F0F0F:0
17780x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
17790xF0F0F0F0F0:0xF0F0F0F0F0:0
17800x0F0F0F0F0F:0x0F0F0F0F0F:0
17810x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
17820xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
17830x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
17840x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1785&bnot
1786abc:NaN
1787+0:-1
1788+8:-9
1789+281474976710656:-281474976710657
1790-1:0
1791-2:1
1792-12:11
1793&digit
17940:0:0
179512:0:2
179612:1:1
1797123:0:3
1798123:1:2
1799123:2:1
1800123:-1:1
1801123:-2:2
1802123:-3:3
1803123456:0:6
1804123456:1:5
1805123456:2:4
1806123456:3:3
1807123456:4:2
1808123456:5:1
1809123456:-1:1
1810123456:-2:2
1811123456:-3:3
1812100000:-3:0
1813100000:0:0
1814100000:1:0
1815&mantissa
1816abc:NaN
18171e4:1
18182e0:2
1819123:123
1820-1:-1
1821-2:-2
1822+inf:inf
1823-inf:-inf
1824&exponent
1825abc:NaN
18261e4:4
18272e0:0
1828123:0
1829-1:0
1830-2:0
18310:1
1832+inf:inf
1833-inf:inf
1834&parts
1835abc:NaN,NaN
18361e4:1,4
18372e0:2,0
1838123:123,0
1839-1:-1,0
1840-2:-2,0
18410:0,1
1842+inf:inf,inf
1843-inf:-inf,inf
b3abae2a 1844&bfac
1845-1:NaN
1846NaNfac:NaN
1847+inf:NaN
1848-inf:NaN
18490:1
18501:1
18512:2
18523:6
18534:24
18545:120
18556:720
990fb837 18567:5040
18578:40320
18589:362880
b3abae2a 185910:3628800
186011:39916800
186112:479001600
6854fd01 1862&bpow
1863abc:12:NaN
186412:abc:NaN
18650:0:1
18660:1:0
18670:2:0
18680:-1:NaN
18690:-2:NaN
18701:0:1
18711:1:1
18721:2:1
18731:3:1
18741:-1:1
18751:-2:1
18761:-3:1
18772:0:1
18782:1:2
18792:2:4
18802:3:8
18813:3:27
18822:-1:NaN
1883-2:-1:NaN
18842:-2:NaN
1885-2:-2:NaN
1886+inf:1234500012:inf
1887-inf:1234500012:-inf
1888+inf:-12345000123:inf
1889-inf:-12345000123:-inf
1890# 1 ** -x => 1 / (1 ** x)
1891-1:0:1
1892-2:0:1
1893-1:1:-1
1894-1:2:1
1895-1:3:-1
1896-1:4:1
1897-1:5:-1
1898-1:-1:-1
1899-1:-2:1
1900-1:-3:-1
1901-1:-4:1
190210:2:100
190310:3:1000
190410:4:10000
190510:5:100000
190610:6:1000000
190710:7:10000000
190810:8:100000000
190910:9:1000000000
191010:20:100000000000000000000
1911123456:2:15241383936
1912&length
1913100:3
191410:2
19151:1
19160:1
191712345:5
191810000000000000000:17
1919-123:3
1920215960156869840440586892398248:30
990fb837 1921&broot
1922# sqrt()
1923+0:2:0
1924+1:2:1
1925-1:2:NaN
1926# -$x ** (1/2) => -$y, but not in froot()
1927-123:2:NaN
1928+inf:2:inf
1929-inf:2:NaN
19302:2:1
1931-2:2:NaN
19324:2:2
19339:2:3
193416:2:4
1935100:2:10
1936123:2:11
193715241:2:123
1938144:2:12
193912:2:3
19400.49:2:0
19410.0049:2:0
1942# invalid ones
19431:NaN:NaN
1944-1:NaN:NaN
19450:NaN:NaN
1946-inf:NaN:NaN
1947+inf:NaN:NaN
1948NaN:0:NaN
1949NaN:2:NaN
1950NaN:inf:NaN
1951NaN:inf:NaN
195212:-inf:NaN
195312:inf:NaN
1954+0:0:NaN
1955+1:0:NaN
1956-1:0:NaN
1957-2:0:NaN
1958-123.45:0:NaN
1959+inf:0:NaN
196012:1:12
1961-12:1:NaN
19628:-1:NaN
1963-8:-1:NaN
1964# cubic root
19658:3:2
1966-8:3:NaN
1967# fourths root
c38b2de2 196816:4:2
196981:4:3
1970# 2 ** 32
197118446744073709551616:4:65536
197218446744073709551616:8:256
197318446744073709551616:16:16
197418446744073709551616:32:4
197518446744073709551616:64:2
197618446744073709551616:128:1
6854fd01 1977&bsqrt
394e6ffb 1978145:12
6854fd01 1979144:12
394e6ffb 1980143:11
6854fd01 198116:4
394e6ffb 1982170:13
1983169:13
1984168:12
6854fd01 19854:2
394e6ffb 19863:1
6854fd01 19872:1
394e6ffb 19889:3
6854fd01 198912:3
1990256:16
1991100000000:10000
19924000000000000:2000000
394e6ffb 1993152399026:12345
1994152399025:12345
1995152399024:12344
6854fd01 19961:1
19970:0
1998-2:NaN
394e6ffb 1999-123:NaN
6854fd01 2000Nan:NaN
990fb837 2001+inf:inf
2002-inf:NaN
6854fd01 2003&bround
2004$round_mode('trunc')
20050:12:0
2006NaNbround:12:NaN
2007+inf:12:inf
2008-inf:12:-inf
20091234:0:1234
20101234:2:1200
2011123456:4:123400
2012123456:5:123450
2013123456:6:123456
61f5c3f5 2014+10123456789:5:10123000000
6854fd01 2015-10123456789:5:-10123000000
61f5c3f5 2016+10123456789:9:10123456700
6854fd01 2017-10123456789:9:-10123456700
61f5c3f5 2018+101234500:6:101234000
6854fd01 2019-101234500:6:-101234000
61f5c3f5 2020#+101234500:-4:101234000
6854fd01 2021#-101234500:-4:-101234000
2022$round_mode('zero')
61f5c3f5 2023+20123456789:5:20123000000
6854fd01 2024-20123456789:5:-20123000000
61f5c3f5 2025+20123456789:9:20123456800
6854fd01 2026-20123456789:9:-20123456800
61f5c3f5 2027+201234500:6:201234000
6854fd01 2028-201234500:6:-201234000
61f5c3f5 2029#+201234500:-4:201234000
6854fd01 2030#-201234500:-4:-201234000
2031+12345000:4:12340000
2032-12345000:4:-12340000
2033$round_mode('+inf')
61f5c3f5 2034+30123456789:5:30123000000
6854fd01 2035-30123456789:5:-30123000000
61f5c3f5 2036+30123456789:9:30123456800
6854fd01 2037-30123456789:9:-30123456800
61f5c3f5 2038+301234500:6:301235000
6854fd01 2039-301234500:6:-301234000
61f5c3f5 2040#+301234500:-4:301235000
6854fd01 2041#-301234500:-4:-301234000
2042+12345000:4:12350000
2043-12345000:4:-12340000
2044$round_mode('-inf')
61f5c3f5 2045+40123456789:5:40123000000
6854fd01 2046-40123456789:5:-40123000000
61f5c3f5 2047+40123456789:9:40123456800
6854fd01 2048-40123456789:9:-40123456800
61f5c3f5 2049+401234500:6:401234000
2050+401234500:6:401234000
6854fd01 2051#-401234500:-4:-401235000
2052#-401234500:-4:-401235000
2053+12345000:4:12340000
2054-12345000:4:-12350000
2055$round_mode('odd')
61f5c3f5 2056+50123456789:5:50123000000
6854fd01 2057-50123456789:5:-50123000000
61f5c3f5 2058+50123456789:9:50123456800
6854fd01 2059-50123456789:9:-50123456800
61f5c3f5 2060+501234500:6:501235000
6854fd01 2061-501234500:6:-501235000
61f5c3f5 2062#+501234500:-4:501235000
6854fd01 2063#-501234500:-4:-501235000
2064+12345000:4:12350000
2065-12345000:4:-12350000
2066$round_mode('even')
61f5c3f5 2067+60123456789:5:60123000000
6854fd01 2068-60123456789:5:-60123000000
61f5c3f5 2069+60123456789:9:60123456800
6854fd01 2070-60123456789:9:-60123456800
61f5c3f5 2071+601234500:6:601234000
6854fd01 2072-601234500:6:-601234000
61f5c3f5 2073#+601234500:-4:601234000
6854fd01 2074#-601234500:-4:-601234000
2075#-601234500:-9:0
2076#-501234500:-9:0
2077#-601234500:-8:0
2078#-501234500:-8:0
2079+1234567:7:1234567
2080+1234567:6:1234570
2081+12345000:4:12340000
2082-12345000:4:-12340000
2083&is_zero
20840:1
2085NaNzero:0
2086+inf:0
2087-inf:0
2088123:0
2089-1:0
20901:0
2091&is_one
20920:0
2093NaNone:0
2094+inf:0
2095-inf:0
20961:1
20972:0
2098-1:0
2099-2:0
2100# floor and ceil tests are pretty pointless in integer space...but play safe
2101&bfloor
21020:0
2103NaNfloor:NaN
2104+inf:inf
2105-inf:-inf
2106-1:-1
2107-2:-2
21082:2
21093:3
2110abc:NaN
2111&bceil
2112NaNceil:NaN
2113+inf:inf
2114-inf:-inf
21150:0
2116-1:-1
2117-2:-2
21182:2
21193:3
2120abc:NaN
2121&as_hex
2122128:0x80
2123-128:-0x80
21240:0x0
2125-0:0x0
21261:0x1
21270x123456789123456789:0x123456789123456789
2128+inf:inf
2129-inf:-inf
2130NaNas_hex:NaN
2131&as_bin
2132128:0b10000000
2133-128:-0b10000000
21340:0b0
2135-0:0b0
21361:0b1
21370b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1ddff52a 21380x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001
6854fd01 2139+inf:inf
2140-inf:-inf
2141NaNas_bin:NaN