This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document string- and number-specific bitops in perlop
[perl5.git] / dist / Math-BigInt / t / bigintpm.inc
CommitLineData
6854fd01
JH
1#include this file into another for subclass testing
2
3my $version = ${"$class\::VERSION"};
4
56d9de68
T
5use strict;
6
6854fd01
JH
7##############################################################################
8# for testing inheritance of _swap
9
10package Math::Foo;
11
61f5c3f5 12use Math::BigInt lib => $main::CL;
6854fd01
JH
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
3167abe5 39my $CALC = $class->config()->{lib}; is ($CALC,$CL);
6854fd01 40
b3abae2a 41my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class);
6854fd01
JH
42
43while (<DATA>)
44 {
f7f86b73 45 $_ =~ s/[\n\r]//g; # remove newlines
6854fd01
JH
46 next if /^#/; # skip comments
47 if (s/^&//)
48 {
61f5c3f5 49 $f = $_; next;
6854fd01
JH
50 }
51 elsif (/^\$/)
52 {
61f5c3f5 53 $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next;
6854fd01 54 }
61f5c3f5
T
55
56 @args = split(/:/,$_,99); $ans = pop(@args);
b3abae2a
JH
57 $expected_class = $class;
58 if ($ans =~ /(.*?)=(.*)/)
59 {
60 $expected_class = $2; $ans = $1;
61 }
61f5c3f5
T
62 $try = "\$x = $class->new(\"$args[0]\");";
63 if ($f eq "bnorm")
6854fd01 64 {
61f5c3f5
T
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
T
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
6358232b 76 } elsif ($f =~ /^b(nan|floor|ceil|int|sstr|neg|abs|sgn|inc|dec|not|sqrt|fac)$/) {
61f5c3f5 77 $try .= "\$x->$f();";
56d9de68
T
78 } elsif ($f =~ /^(numify|length|stringify|as_hex|as_bin)$/) {
79 $try .= "\$x->$f();";
61f5c3f5
T
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";';
50109ad0
RGS
92 }elsif ($f eq "bexp"){
93 $try .= "\$x->bexp();";
fdb4b05f
T
94 } elsif ($f eq "bpi"){
95 $try .= "$class\->bpi(\$x);";
61f5c3f5 96 } else {
56d9de68 97 # binary ops
61f5c3f5
T
98 $try .= "\$y = $class->new('$args[1]');";
99 if ($f eq "bcmp")
100 {
a0ac753d 101 $try .= '$x->bcmp($y);';
61f5c3f5 102 } elsif ($f eq "bround") {
6854fd01 103 $try .= "$round_mode; \$x->bround(\$y);";
61f5c3f5
T
104 } elsif ($f eq "bacmp"){
105 $try .= '$x->bacmp($y);';
106 } elsif ($f eq "badd"){
107 $try .= '$x + $y;';
108 } elsif ($f eq "bsub"){
109 $try .= '$x - $y;';
110 } elsif ($f eq "bmul"){
111 $try .= '$x * $y;';
112 } elsif ($f eq "bdiv"){
113 $try .= '$x / $y;';
114 } elsif ($f eq "bdiv-list"){
115 $try .= 'join (",",$x->bdiv($y));';
027dc388 116 # overload via x=
61f5c3f5
T
117 } elsif ($f =~ /^.=$/){
118 $try .= "\$x $f \$y;";
027dc388 119 # overload via x
61f5c3f5
T
120 } elsif ($f =~ /^.$/){
121 $try .= "\$x $f \$y;";
122 } elsif ($f eq "bmod"){
123 $try .= '$x % $y;';
124 } elsif ($f eq "bgcd")
6854fd01
JH
125 {
126 if (defined $args[2])
127 {
61f5c3f5 128 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01
JH
129 }
130 $try .= "$class\::bgcd(\$x, \$y";
131 $try .= ", \$z" if (defined $args[2]);
132 $try .= " );";
133 }
134 elsif ($f eq "blcm")
135 {
136 if (defined $args[2])
137 {
61f5c3f5 138 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01
JH
139 }
140 $try .= "$class\::blcm(\$x, \$y";
141 $try .= ", \$z" if (defined $args[2]);
142 $try .= " );";
143 }elsif ($f eq "blsft"){
144 if (defined $args[2])
145 {
146 $try .= "\$x->blsft(\$y,$args[2]);";
147 }
148 else
149 {
150 $try .= "\$x << \$y;";
151 }
152 }elsif ($f eq "brsft"){
153 if (defined $args[2])
154 {
155 $try .= "\$x->brsft(\$y,$args[2]);";
156 }
157 else
158 {
159 $try .= "\$x >> \$y;";
160 }
50109ad0
RGS
161 }elsif ($f eq "bnok"){
162 $try .= "\$x->bnok(\$y);";
990fb837
RGS
163 }elsif ($f eq "broot"){
164 $try .= "\$x->broot(\$y);";
091c87b1
T
165 }elsif ($f eq "blog"){
166 $try .= "\$x->blog(\$y);";
6854fd01
JH
167 }elsif ($f eq "band"){
168 $try .= "\$x & \$y;";
169 }elsif ($f eq "bior"){
170 $try .= "\$x | \$y;";
171 }elsif ($f eq "bxor"){
172 $try .= "\$x ^ \$y;";
173 }elsif ($f eq "bpow"){
174 $try .= "\$x ** \$y;";
d614cd8b
JH
175 } elsif( $f eq "bmodinv") {
176 $try .= "\$x->bmodinv(\$y);";
6854fd01 177 }elsif ($f eq "digit"){
56b9c951 178 $try .= "\$x->digit(\$y);";
30afc38d
T
179 }elsif ($f eq "batan2"){
180 $try .= "\$x->batan2(\$y);";
d614cd8b 181 } else {
80365507 182 # Functions with three arguments
d614cd8b
JH
183 $try .= "\$z = $class->new(\"$args[2]\");";
184
d614cd8b
JH
185 if( $f eq "bmodpow") {
186 $try .= "\$x->bmodpow(\$y,\$z);";
80365507
T
187 } elsif ($f eq "bmuladd"){
188 $try .= "\$x->bmuladd(\$y,\$z);";
d614cd8b
JH
189 } else { warn "Unknown op '$f'"; }
190 }
61f5c3f5
T
191 } # end else all other ops
192
193 $ans1 = eval $try;
194 # convert hex/binary targets to decimal
195 if ($ans =~ /^(0x0x|0b0b)/)
196 {
197 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 198 }
61f5c3f5
T
199 if ($ans eq "")
200 {
3167abe5 201 is ($ans1, undef);
61f5c3f5
T
202 }
203 else
204 {
205 # print "try: $try ans: $ans1 $ans\n";
3167abe5
NC
206 print "# Tried: '$try'\n" if !is ($ans1, $ans);
207 is (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 208 }
61f5c3f5
T
209 # check internal state of number objects
210 is_valid($ans1,$f) if ref $ans1;
6854fd01
JH
211 } # endwhile data tests
212close DATA;
213
214# test some more
215@a = ();
216for (my $i = 1; $i < 10; $i++)
217 {
218 push @a, $i;
219 }
3167abe5 220is("@a", "1 2 3 4 5 6 7 8 9");
6854fd01
JH
221
222# test whether self-multiplication works correctly (result is 2**64)
223$try = "\$x = $class->new('4294967296');";
224$try .= '$a = $x->bmul($x);';
225$ans1 = eval $try;
3167abe5 226print "# Tried: '$try'\n" if !is ($ans1, $class->new(2) ** 64);
6854fd01
JH
227# test self-pow
228$try = "\$x = $class->new(10);";
229$try .= '$a = $x->bpow($x);';
230$ans1 = eval $try;
3167abe5 231print "# Tried: '$try'\n" if !is ($ans1, $class->new(10) ** 10);
6854fd01 232
07d34614 233###############################################################################
6854fd01
JH
234# test whether op destroys args or not (should better not)
235
236$x = $class->new(3);
237$y = $class->new(4);
238$z = $x & $y;
3167abe5
NC
239is ($x,3);
240is ($y,4);
241is ($z,0);
6854fd01 242$z = $x | $y;
3167abe5
NC
243is ($x,3);
244is ($y,4);
245is ($z,7);
6854fd01
JH
246$x = $class->new(1);
247$y = $class->new(2);
248$z = $x | $y;
3167abe5
NC
249is ($x,1);
250is ($y,2);
251is ($z,3);
6854fd01
JH
252
253$x = $class->new(5);
254$y = $class->new(4);
255$z = $x ^ $y;
3167abe5
NC
256is ($x,5);
257is ($y,4);
258is ($z,1);
6854fd01
JH
259
260$x = $class->new(-5); $y = -$x;
3167abe5 261is ($x, -5);
6854fd01
JH
262
263$x = $class->new(-5); $y = abs($x);
3167abe5 264is ($x, -5);
6854fd01 265
07d34614
T
266$x = $class->new(8);
267$y = $class->new(-1);
268$z = $class->new(5033);
269my $u = $x->copy()->bmodpow($y,$z);
3167abe5
NC
270is ($u,4404);
271is ($y,-1);
272is ($z,5033);
273
274$x = $class->new(-5); $y = -$x; is ($x,-5); is ($y,5);
275$x = $class->new(-5); $y = $x->copy()->bneg(); is ($x,-5); is ($y,5);
276
277$x = $class->new(-5); $y = $class->new(3); $x->bmul($y); is ($x,-15); is ($y,3);
278$x = $class->new(-5); $y = $class->new(3); $x->badd($y); is ($x,-2); is ($y,3);
279$x = $class->new(-5); $y = $class->new(3); $x->bsub($y); is ($x,-8); is ($y,3);
280$x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); is ($x,-5); is ($y,3);
281$x = $class->new(-5); $y = $class->new(3); $x->bmod($y); is ($x,1); is ($y,3);
282
283$x = $class->new(5); $y = $class->new(3); $x->bmul($y); is ($x,15); is ($y,3);
284$x = $class->new(5); $y = $class->new(3); $x->badd($y); is ($x,8); is ($y,3);
285$x = $class->new(5); $y = $class->new(3); $x->bsub($y); is ($x,2); is ($y,3);
286$x = $class->new(15); $y = $class->new(3); $x->bdiv($y); is ($x,5); is ($y,3);
287$x = $class->new(5); $y = $class->new(3); $x->bmod($y); is ($x,2); is ($y,3);
288
289$x = $class->new(5); $y = $class->new(-3); $x->bmul($y); is ($x,-15); is ($y,-3);
290$x = $class->new(5); $y = $class->new(-3); $x->badd($y); is ($x,2); is ($y,-3);
291$x = $class->new(5); $y = $class->new(-3); $x->bsub($y); is ($x,8); is ($y,-3);
292$x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); is ($x,-5); is ($y,-3);
293$x = $class->new(5); $y = $class->new(-3); $x->bmod($y); is ($x,-1); is ($y,-3);
07d34614
T
294
295###############################################################################
6854fd01
JH
296# check whether overloading cmp works
297$try = "\$x = $class->new(0);";
298$try .= "\$y = 10;";
299$try .= "'false' if \$x ne \$y;";
300$ans = eval $try;
3167abe5 301print "# For '$try'\n" if (!is ("$ans" , "false") );
6854fd01
JH
302
303# we cant test for working cmpt with other objects here, we would need a dummy
304# object with stringify overload for this. see Math::String tests as example
305
306###############################################################################
6854fd01 307# check reversed order of arguments
027dc388 308
6854fd01
JH
309$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
310$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
311print "# For '$try'\n" if (!ok "$ans" , "ok" );
312
313$try = "\$x = $class->new(10); \$x = 2 * \$x;";
314$try .= "'ok' if \$x == 20;"; $ans = eval $try;
315print "# For '$try'\n" if (!ok "$ans" , "ok" );
316
317$try = "\$x = $class->new(10); \$x = 2 + \$x;";
318$try .= "'ok' if \$x == 12;"; $ans = eval $try;
319print "# For '$try'\n" if (!ok "$ans" , "ok" );
320
321$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
322$try .= "'ok' if \$x == -8;"; $ans = eval $try;
323print "# For '$try'\n" if (!ok "$ans" , "ok" );
324
325$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
326$try .= "'ok' if \$x == 2;"; $ans = eval $try;
327print "# For '$try'\n" if (!ok "$ans" , "ok" );
328
027dc388
JH
329$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
330$try .= "'ok' if \$x == 2;"; $ans = eval $try;
331print "# For '$try'\n" if (!ok "$ans" , "ok" );
332
333$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
334$try .= "'ok' if \$x == 4;"; $ans = eval $try;
335print "# For '$try'\n" if (!ok "$ans" , "ok" );
336
337$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
338$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
339print "# For '$try'\n" if (!ok "$ans" , "ok" );
340
341$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
342$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
343print "# For '$try'\n" if (!ok "$ans" , "ok" );
344
6854fd01
JH
345###############################################################################
346# check badd(4,5) form
347
348$try = "\$x = $class\->badd(4,5);";
349$try .= "'ok' if \$x == 9;";
350$ans = eval $try;
351print "# For '$try'\n" if (!ok "$ans" , "ok" );
352
353###############################################################################
354# check undefs: NOT DONE YET
355
356###############################################################################
357# bool
358
3167abe5
NC
359$x = $class->new(1); if ($x) { is (1,1); } else { is ($x,'to be true') }
360$x = $class->new(0); if (!$x) { is (1,1); } else { is ($x,'to be false') }
6854fd01
JH
361
362###############################################################################
363# objectify()
364
365@args = Math::BigInt::objectify(2,4,5);
3167abe5
NC
366is (scalar @args,3); # $class, 4, 5
367like ($args[0], qr/^Math::BigInt/);
368is ($args[1],4);
369is ($args[2],5);
6854fd01
JH
370
371@args = Math::BigInt::objectify(0,4,5);
3167abe5
NC
372is (scalar @args,3); # $class, 4, 5
373like ($args[0], qr/^Math::BigInt/);
374is ($args[1],4);
375is ($args[2],5);
6854fd01
JH
376
377@args = Math::BigInt::objectify(2,4,5);
3167abe5
NC
378is (scalar @args,3); # $class, 4, 5
379like ($args[0], qr/^Math::BigInt/);
380is ($args[1],4);
381is ($args[2],5);
6854fd01
JH
382
383@args = Math::BigInt::objectify(2,4,5,6,7);
3167abe5
NC
384is (scalar @args,5); # $class, 4, 5, 6, 7
385like ($args[0], qr/^Math::BigInt/);
386is ($args[1],4); is (ref($args[1]),$args[0]);
387is ($args[2],5); is (ref($args[2]),$args[0]);
388is ($args[3],6); is (ref($args[3]),'');
389is ($args[4],7); is (ref($args[4]),'');
6854fd01
JH
390
391@args = Math::BigInt::objectify(2,$class,4,5,6,7);
3167abe5
NC
392is (scalar @args,5); # $class, 4, 5, 6, 7
393is ($args[0],$class);
394is ($args[1],4); is (ref($args[1]),$args[0]);
395is ($args[2],5); is (ref($args[2]),$args[0]);
396is ($args[3],6); is (ref($args[3]),'');
397is ($args[4],7); is (ref($args[4]),'');
6854fd01
JH
398
399###############################################################################
f9a08e12
JH
400# test whether an opp calls objectify properly or not (or at least does what
401# it should do given non-objects, w/ or w/o objectify())
402
3167abe5
NC
403is ($class->new(123)->badd(123),246);
404is ($class->badd(123,321),444);
405is ($class->badd(123,$class->new(321)),444);
f9a08e12 406
3167abe5
NC
407is ($class->new(123)->bsub(122),1);
408is ($class->bsub(321,123),198);
409is ($class->bsub(321,$class->new(123)),198);
f9a08e12 410
3167abe5
NC
411is ($class->new(123)->bmul(123),15129);
412is ($class->bmul(123,123),15129);
413is ($class->bmul(123,$class->new(123)),15129);
f9a08e12 414
3167abe5
NC
415is ($class->new(15129)->bdiv(123),123);
416is ($class->bdiv(15129,123),123);
417is ($class->bdiv(15129,$class->new(123)),123);
f9a08e12 418
3167abe5
NC
419is ($class->new(15131)->bmod(123),2);
420is ($class->bmod(15131,123),2);
421is ($class->bmod(15131,$class->new(123)),2);
f9a08e12 422
3167abe5
NC
423is ($class->new(2)->bpow(16),65536);
424is ($class->bpow(2,16),65536);
425is ($class->bpow(2,$class->new(16)),65536);
f9a08e12 426
3167abe5
NC
427is ($class->new(2**15)->brsft(1),2**14);
428is ($class->brsft(2**15,1),2**14);
429is ($class->brsft(2**15,$class->new(1)),2**14);
f9a08e12 430
3167abe5
NC
431is ($class->new(2**13)->blsft(1),2**14);
432is ($class->blsft(2**13,1),2**14);
433is ($class->blsft(2**13,$class->new(1)),2**14);
f9a08e12
JH
434
435###############################################################################
6854fd01
JH
436# test for floating-point input (other tests in bnorm() below)
437
438$z = 1050000000000000; # may be int on systems with 64bit?
3167abe5 439$x = $class->new($z); is ($x->bsstr(),'105e+13'); # not 1.05e+15
6854fd01
JH
440$z = 1e+129; # definitely a float (may fail on UTS)
441# don't compare to $z, since some Perl versions stringify $z into something
442# like '1.e+129' or something equally ugly
3167abe5 443$x = $class->new($z); is ($x->bsstr(),'1e+129');
6854fd01
JH
444
445###############################################################################
9681bfa6 446# test for whitespace including newlines to be handled correctly
56d9de68 447
3167abe5 448# is ($Math::BigInt::strict,1); # the default
56d9de68
T
449
450foreach my $c (
451 qw/1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890/)
452 {
453 my $m = $class->new($c);
3167abe5
NC
454 is ($class->new("$c"),$m);
455 is ($class->new(" $c"),$m);
456 is ($class->new("$c "),$m);
457 is ($class->new(" $c "),$m);
458 is ($class->new("\n$c"),$m);
459 is ($class->new("$c\n"),$m);
460 is ($class->new("\n$c\n"),$m);
461 is ($class->new(" \n$c\n"),$m);
462 is ($class->new(" \n$c \n"),$m);
463 is ($class->new(" \n$c\n "),$m);
464 is ($class->new(" \n$c\n1"),'NaN');
465 is ($class->new("1 \n$c\n1"),'NaN');
56d9de68
T
466 }
467
468###############################################################################
6854fd01
JH
469# prime number tests, also test for **= and length()
470# found on: http://www.utm.edu/research/primes/notes/by_year.html
471
472# ((2^148)-1)/17
473$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
3167abe5
NC
474is ($x,"20988936657440586486151264256610222593863921");
475is ($x->length(),length "20988936657440586486151264256610222593863921");
6854fd01
JH
476
477# MM7 = 2^127-1
478$x = $class->new(2); $x **= 127; $x--;
3167abe5 479is ($x,"170141183460469231731687303715884105727");
6854fd01
JH
480
481$x = $class->new('215960156869840440586892398248');
482($x,$y) = $x->length();
3167abe5 483is ($x,30); is ($y,0);
6854fd01
JH
484
485$x = $class->new('1_000_000_000_000');
486($x,$y) = $x->length();
3167abe5 487is ($x,13); is ($y,0);
6854fd01 488
2d2b2744
T
489# test <<=, >>=
490$x = $class->new('2');
491my $y = $class->new('18');
3167abe5
NC
492is ($x <<= $y, 2 << 18);
493is ($x, 2 << 18);
494is ($x >>= $y, 2);
495is ($x, 2);
2d2b2744 496
6854fd01
JH
497# I am afraid the following is not yet possible due to slowness
498# Also, testing for 2 meg output is a bit hard ;)
499#$x = $class->new(2); $x **= 6972593; $x--;
500
501# 593573509*2^332162+1 has exactly 1,000,000 digits
502# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
503#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
3167abe5 504#is ($x->length(),1_000_000);
6854fd01
JH
505
506###############################################################################
507# inheritance and overriding of _swap
508
509$x = Math::Foo->new(5);
510$x = $x - 8; # 8 - 5 instead of 5-8
3167abe5
NC
511is ($x,3);
512is (ref($x),'Math::Foo');
6854fd01
JH
513
514$x = Math::Foo->new(5);
515$x = 8 - $x; # 5 - 8 instead of 8 - 5
3167abe5
NC
516is ($x,-3);
517is (ref($x),'Math::Foo');
6854fd01
JH
518
519###############################################################################
520# Test whether +inf eq inf
521# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
522# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
523# like 1e100000 crash on some platforms. So simple test for the string 'inf'
3167abe5 524$x = $class->new('+inf'); is ($x,'inf');
6854fd01
JH
525
526###############################################################################
02916adf
PJA
527# numify() and 64 bit integer support
528
529require Config;
530SKIP: {
531 skip("no 64 bit integer support", 4)
532 unless $Config::Config{use64bitint} || $Config::Config{use64bitall};
533
534 # The following should not give "1.84467440737096e+19".
535
536 $x = $class -> new(2) -> bpow(64) -> bdec();
537 is($x -> bstr(), "18446744073709551615", "bigint 2**64-1 as string");
538 is($x -> numify(), "18446744073709551615", "bigint 2**64-1 as number");
539
540 # The following should not give "-9.22337203685478e+18".
541
542 $x = $class -> new(2) -> bpow(63) -> bneg();
543 is($x -> bstr(), "-9223372036854775808", "bigint -2**63 as string");
544 is($x -> numify(), "-9223372036854775808", "bigint -2**63 as number");
545};
546
547###############################################################################
6854fd01 548###############################################################################
9681bfa6 549# the following tests only make sense with Math::BigInt::Calc or BareCalc or
56d9de68 550# FastCalc
6854fd01 551
56d9de68 552exit if $CALC !~ /^Math::BigInt::(|Bare|Fast)Calc$/; # for Pari et al.
6854fd01
JH
553
554###############################################################################
555# check proper length of internal arrays
556
394e6ffb 557my $bl = $CL->_base_len();
6854fd01
JH
558my $BASE = '9' x $bl;
559my $MAX = $BASE;
560$BASE++;
561
562$x = $class->new($MAX); is_valid($x); # f.i. 9999
3167abe5
NC
563$x += 1; is ($x,$BASE); is_valid($x); # 10000
564$x -= 1; is ($x,$MAX); is_valid($x); # 9999 again
6854fd01
JH
565
566###############################################################################
567# check numify
568
3167abe5
NC
569$x = $class->new($BASE-1); is ($x->numify(),$BASE-1);
570$x = $class->new(-($BASE-1)); is ($x->numify(),-($BASE-1));
61f5c3f5
T
571
572# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
3167abe5
NC
573$x = $class->new($BASE); is ($x->numify()+0,$BASE+0);
574$x = $class->new(-$BASE); is ($x->numify(),-$BASE);
6854fd01 575$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
3167abe5 576is ($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
6854fd01
JH
577
578###############################################################################
579# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
580
394e6ffb 581$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
3167abe5 582if ($x > $BASE) { is (1,1) } else { is ("$x < $BASE","$x > $BASE"); }
394e6ffb
JH
583
584$x = $class->new($BASE+3); $x++;
3167abe5 585if ($x > $BASE) { is (1,1) } else { is ("$x > $BASE","$x < $BASE"); }
6854fd01 586
394e6ffb 587# test for +0 instead of int():
3167abe5 588$x = $class->new($MAX); is ($x->length(), length($MAX));
6854fd01
JH
589
590###############################################################################
56b9c951
JH
591# test bug that $class->digit($string) did not work
592
3167abe5 593is ($class->digit(123,2),1);
56b9c951
JH
594
595###############################################################################
6854fd01
JH
596# bug in sub where number with at least 6 trailing zeros after any op failed
597
394e6ffb 598$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
3167abe5
NC
599is ($z, 100000);
600is ($x, 23456);
6854fd01
JH
601
602###############################################################################
603# bug in shortcut in mul()
604
61f5c3f5
T
605# construct a number with a zero-hole of BASE_LEN_SMALL
606{
f800d0e1 607 my @bl = $CL->_base_len(); my $bl = $bl[5];
61f5c3f5
T
608
609 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
610 $y = '1' x (2*$bl);
611 $x = $class->new($x)->bmul($y);
612 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
613 $y = ''; my $d = '';
614 for (my $i = 1; $i <= $bl; $i++)
615 {
616 $y .= $i; $d = $i.$d;
617 }
618 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
3167abe5 619 is ($x,$y);
61f5c3f5 620
6854fd01 621
f9a08e12
JH
622 #############################################################################
623 # see if mul shortcut for small numbers works
394e6ffb 624
f9a08e12
JH
625 $x = '9' x $bl;
626 $x = $class->new($x);
627 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
3167abe5 628 is ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
f9a08e12 629}
61f5c3f5 630
394e6ffb 631###############################################################################
6854fd01
JH
632# bug with rest "-0" in div, causing further div()s to fail
633
394e6ffb 634$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 635
3167abe5 636is ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 637
79c55733 638###############################################################################
f9a08e12 639# bug in $x->bmod($y)
07d34614 640
f9a08e12 641# if $x < 0 and $y > 0
3167abe5 642$x = $class->new('-629'); is ($x->bmod(5033),4404);
07d34614
T
643
644###############################################################################
56b9c951
JH
645# bone/binf etc as plain calls (Lite failed them)
646
3167abe5
NC
647is ($class->bzero(),0);
648is ($class->bone(),1);
649is ($class->bone('+'),1);
650is ($class->bone('-'),-1);
651is ($class->bnan(),'NaN');
652is ($class->binf(),'inf');
653is ($class->binf('+'),'inf');
654is ($class->binf('-'),'-inf');
655is ($class->binf('-inf'),'-inf');
56b9c951
JH
656
657###############################################################################
990fb837
RGS
658# is_one('-')
659
3167abe5
NC
660is ($class->new(1)->is_one('-'),0);
661is ($class->new(-1)->is_one('-'),1);
662is ($class->new(1)->is_one(),1);
663is ($class->new(-1)->is_one(),0);
990fb837
RGS
664
665###############################################################################
0ac635f7 666# [perl #30609] bug with $x -= $x not being 0, but 2*$x
03874afe 667
3167abe5
NC
668$x = $class->new(3); $x -= $x; is ($x, 0);
669$x = $class->new(-3); $x -= $x; is ($x, 0);
670$x = $class->new('NaN'); $x -= $x; is ($x->is_nan(), 1);
671$x = $class->new('inf'); $x -= $x; is ($x->is_nan(), 1);
672$x = $class->new('-inf'); $x -= $x; is ($x->is_nan(), 1);
673
674$x = $class->new('NaN'); $x += $x; is ($x->is_nan(), 1);
675$x = $class->new('inf'); $x += $x; is ($x->is_inf(), 1);
676$x = $class->new('-inf'); $x += $x; is ($x->is_inf('-'), 1);
677$x = $class->new(3); $x += $x; is ($x, 6);
678$x = $class->new(-3); $x += $x; is ($x, -6);
679
680$x = $class->new(3); $x *= $x; is ($x, 9);
681$x = $class->new(-3); $x *= $x; is ($x, 9);
682$x = $class->new(3); $x /= $x; is ($x, 1);
683$x = $class->new(-3); $x /= $x; is ($x, 1);
684$x = $class->new(3); $x %= $x; is ($x, 0);
685$x = $class->new(-3); $x %= $x; is ($x, 0);
03874afe
T
686
687###############################################################################
61f5c3f5 688# all tests done
6854fd01
JH
689
6901;
691
692###############################################################################
6854fd01
JH
693# sub to check validity of a BigInt internally, to ensure that no op leaves a
694# number object in an invalid state (f.i. "-0")
695
696sub is_valid
697 {
698 my ($x,$f) = @_;
699
700 my $e = 0; # error?
6854fd01 701
56b9c951
JH
702 # allow the check to pass for all Lite, and all MBI and subclasses
703 # ok as reference?
704 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 705
56b9c951
JH
706 if (ref($x) ne 'Math::BigInt::Lite')
707 {
708 # has ok sign?
709 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
710 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
711
712 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
713 $e = $CALC->_check($x->{value}) if $e eq '0';
714 }
6854fd01
JH
715
716 # test done, see if error did crop up
3167abe5 717 is (1,1), return if ($e eq '0');
6854fd01 718
3167abe5 719 is (1,$e." after op '$f'");
6854fd01
JH
720 }
721
722__DATA__
027dc388
JH
723&.=
7241234:-345:1234-345
725&+=
7261:2:3
727-1:-2:-3
728&-=
7291:2:-1
730-1:-2:1
731&*=
7322:3:6
733-1:5:-5
734&%=
735100:3:1
7368:9:8
07d34614 737-629:5033:4404
027dc388
JH
738&/=
739100:3:33
740-8:2:-4
741&|=
7422:1:3
743&&=
7445:7:5
745&^=
7465:7:2
091c87b1
T
747&blog
748NaNlog:2:NaN
749122:NaNlog:NaN
750NaNlog1:NaNlog:NaN
751122:inf:NaN
752inf:122:NaN
753122:-inf:NaN
754-inf:122:NaN
755-inf:-inf:NaN
756inf:inf:NaN
7570:4:NaN
758-21:4:NaN
75921:-21:NaN
760# normal results
7611024:2:10
76281:3:4
763# 3.01.. truncate
76482:3:4
765# 3.9... truncate
76680:3:3
76715625:5:6
76815626:5:6
76915624:5:5
8df1e0a2
T
7701000:10:3
77110000:10:4
772100000:10:5
7731000000:10:6
77410000000:10:7
775100000000:10:8
7768916100448256:12:12
7778916100448257:12:12
7788916100448255:12:11
7792251799813685248:8:17
78072057594037927936:2:56
781144115188075855872:2:57
782288230376151711744:2:58
783576460752303423488:2:59
7844096:2:12
7851329227995784915872903807060280344576:2:120
091c87b1
T
786# $x == $base => result 1
7873:3:1
788# $x < $base => result 0 ($base ** 0 <= $x)
7893:4:0
790# $x == 1 => result 0
7911:5:0
6854fd01
JH
792&is_negative
7930:0
794-1:1
7951:0
796+inf:0
797-inf:1
798NaNneg:0
799&is_positive
b68b7ab1 8000:0
6854fd01
JH
801-1:0
8021:1
803+inf:1
804-inf:0
805NaNneg:0
b3abae2a
JH
806&is_int
807-inf:0
808+inf:0
809NaNis_int:0
8101:1
8110:1
812123e12:1
6854fd01
JH
813&is_odd
814abc:0
8150:0
8161:1
8173:1
818-1:1
819-3:1
82010000001:1
82110000002:0
8222:0
b3abae2a
JH
823120:0
824121:1
6854fd01
JH
825&is_even
826abc:0
8270:1
8281:0
8293:0
830-1:0
831-3:0
83210000001:0
83310000002:1
8342:1
b3abae2a
JH
835120:1
836121:0
6854fd01
JH
837&bacmp
838+0:-0:0
839+0:+1:-1
840-1:+1:0
841+1:-1:0
842-1:+2:-1
843+2:-1:1
844-123456789:+987654321:-1
845+123456789:-987654321:-1
846+987654321:+123456789:1
847-987654321:+123456789:1
848-123:+4567889:-1
849# NaNs
850acmpNaN:123:
851123:acmpNaN:
852acmpNaN:acmpNaN:
853# infinity
854+inf:+inf:0
855-inf:-inf:0
856+inf:-inf:0
857-inf:+inf:0
858+inf:123:1
859-inf:123:1
860+inf:-123:1
861-inf:-123:1
ef9466ea
T
862123:-inf:-1
863-123:inf:-1
864-123:-inf:-1
865123:inf:-1
6854fd01
JH
866# return undef
867+inf:NaN:
868NaN:inf:
869-inf:NaN:
870NaN:-inf:
871&bnorm
aef458a0
JH
8720e999:0
8730e-999:0
874-0e999:0
875-0e-999:0
6854fd01
JH
876123:123
877# binary input
8780babc:NaN
8790b123:NaN
8800b0:0
881-0b0:0
882-0b1:-1
8830b0001:1
8840b001:1
8850b011:3
8860b101:5
61f5c3f5
T
8870b1001:9
8880b10001:17
8890b100001:33
8900b1000001:65
8910b10000001:129
8920b100000001:257
8930b1000000001:513
8940b10000000001:1025
8950b100000000001:2049
8960b1000000000001:4097
8970b10000000000001:8193
8980b100000000000001:16385
8990b1000000000000001:32769
9000b10000000000000001:65537
9010b100000000000000001:131073
9020b1000000000000000001:262145
9030b10000000000000000001:524289
9040b100000000000000000001:1048577
9050b1000000000000000000001:2097153
9060b10000000000000000000001:4194305
9070b100000000000000000000001:8388609
9080b1000000000000000000000001:16777217
9090b10000000000000000000000001:33554433
9100b100000000000000000000000001:67108865
9110b1000000000000000000000000001:134217729
9120b10000000000000000000000000001:268435457
9130b100000000000000000000000000001:536870913
9140b1000000000000000000000000000001:1073741825
9150b10000000000000000000000000000001:2147483649
9160b100000000000000000000000000000001:4294967297
9170b1000000000000000000000000000000001:8589934593
9180b10000000000000000000000000000000001:17179869185
de1ac46b 9190b__101:NaN
6854fd01 9200b1_0_1:5
394e6ffb 9210b0_0_0_1:1
6854fd01
JH
922# hex input
923-0x0:0
9240xabcdefgh:NaN
9250x1234:4660
9260xabcdef:11259375
927-0xABCDEF:-11259375
928-0x1234:-4660
9290x12345678:305419896
9300x1_2_3_4_56_78:305419896
394e6ffb 9310xa_b_c_d_e_f:11259375
de1ac46b 9320x__123:NaN
61f5c3f5
T
9330x9:9
9340x11:17
9350x21:33
9360x41:65
9370x81:129
9380x101:257
9390x201:513
9400x401:1025
9410x801:2049
9420x1001:4097
9430x2001:8193
9440x4001:16385
9450x8001:32769
9460x10001:65537
9470x20001:131073
9480x40001:262145
9490x80001:524289
9500x100001:1048577
9510x200001:2097153
9520x400001:4194305
9530x800001:8388609
9540x1000001:16777217
9550x2000001:33554433
9560x4000001:67108865
9570x8000001:134217729
9580x10000001:268435457
9590x20000001:536870913
9600x40000001:1073741825
9610x80000001:2147483649
9620x100000001:4294967297
9630x200000001:8589934593
9640x400000001:17179869185
9650x800000001:34359738369
2d2b2744
T
966# bug found by Mark Lakata in Calc.pm creating too big one-element numbers in _from_hex()
9670x2dd59e18a125dbed30a6ab1d93e9c855569f44f75806f0645dc9a2e98b808c3:1295719234436071846486578237372801883390756472611551858964079371952886122691
6854fd01
JH
968# inf input
969inf:inf
970+inf:inf
971-inf:-inf
9720inf:NaN
027dc388 973# abnormal input
6854fd01
JH
974:NaN
975abc:NaN
976 1 a:NaN
9771bcd2:NaN
97811111b:NaN
979+1z:NaN
980-1z:NaN
027dc388
JH
981# only one underscore between two digits
982_123:NaN
983_123_:NaN
984123_:NaN
9851__23:NaN
9861E1__2:NaN
9871_E12:NaN
9881E_12:NaN
9891_E_12:NaN
990+_1E12:NaN
991+0_1E2:100
992+0_0_1E2:100
993-0_0_1E2:-100
994-0_0_1E+0_0_2:-100
995E1:NaN
996E23:NaN
9971.23E1:NaN
9981.23E-1:NaN
0ac635f7 999# bug with two E's in number being valid
027dc388
JH
10001e2e3:NaN
10011e2r:NaN
10021e2.0:NaN
0ac635f7 1003# bug with two '.' in number being valid
07d34614
T
10041.2.2:NaN
10051.2.3e1:NaN
1006-1.2.3:NaN
1007-1.2.3e-4:NaN
10081.2e3.4:NaN
10091.2e-3.4:NaN
10101.2.3.4:NaN
10111.2.t:NaN
10121..2:NaN
10131..2e1:NaN
10141..2e1..1:NaN
101512e1..1:NaN
1016..2:NaN
1017.-2:NaN
61f5c3f5
T
1018# leading zeros
1019012:12
10200123:123
102101234:1234
1022012345:12345
10230123456:123456
102401234567:1234567
1025012345678:12345678
10260123456789:123456789
102701234567891:1234567891
1028012345678912:12345678912
10290123456789123:123456789123
103001234567891234:1234567891234
2d2b2744
T
1031# some inputs that result in zero
10320e0:0
1033+0e0:0
1034+0e+0:0
1035-0e+0:0
10360e-0:0
1037-0e-0:0
1038+0e-0:0
1039000:0
104000e2:0
104100e02:0
1042000e002:0
1043000e1230:0
104400e-3:0
104500e+3:0
104600e-03:0
104700e+03:0
1048-000:0
1049-00e2:0
1050-00e02:0
1051-000e002:0
1052-000e1230:0
1053-00e-3:0
1054-00e+3:0
1055-00e-03:0
1056-00e+03:0
027dc388 1057# normal input
6854fd01
JH
10580:0
1059+0:0
1060+00:0
1061+000:0
1062000000000000000000:0
1063-0:0
1064-0000:0
1065+1:1
1066+01:1
1067+001:1
1068+00000100000:100000
1069123456789:123456789
1070-1:-1
1071-01:-1
1072-001:-1
1073-123456789:-123456789
1074-00000100000:-100000
10751_2_3:123
6854fd01
JH
107610000000000E-1_0:1
10771E2:100
10781E1:10
10791E0:1
6854fd01 10801.23E2:123
6854fd01
JH
1081100E-1:10
1082# floating point input
027dc388
JH
1083# .2e2:20
10841.E3:1000
6854fd01
JH
10851.01E2:101
10861010E-1:101
1087-1010E0:-1010
1088-1010E1:-10100
027dc388
JH
10891234.00:1234
1090# non-integer numbers
6854fd01
JH
1091-1010E-2:NaN
1092-1.01E+1:NaN
1093-1.01E-1:NaN
6854fd01
JH
1094&bnan
10951:NaN
10962:NaN
1097abc:NaN
1098&bone
61f5c3f5 10992:+:1
6854fd01
JH
11002:-:-1
1101boneNaN:-:-1
61f5c3f5
T
1102boneNaN:+:1
11032:abc:1
11043::1
6854fd01
JH
1105&binf
11061:+:inf
11072:-:-inf
11083:abc:inf
027dc388
JH
1109&is_nan
1110123:0
1111abc:1
1112NaN:1
1113-123:0
6854fd01
JH
1114&is_inf
1115+inf::1
1116-inf::1
1117abc::0
11181::0
1119NaN::0
1120-1::0
1121+inf:-:0
1122+inf:+:1
1123-inf:-:1
1124-inf:+:0
79c55733
JH
1125-inf:-inf:1
1126-inf:+inf:0
1127+inf:-inf:0
1128+inf:+inf:1
6854fd01
JH
1129# it must be exactly /^[+-]inf$/
1130+infinity::0
1131-infinity::0
1132&blsft
1133abc:abc:NaN
61f5c3f5
T
1134+2:+2:8
1135+1:+32:4294967296
1136+1:+48:281474976710656
6854fd01 1137+8:-2:NaN
a9ccbcd7 1138# exercise base 10
6854fd01
JH
1139+12345:4:10:123450000
1140-1234:0:10:-1234
61f5c3f5 1141+1234:0:10:1234
6854fd01
JH
1142+2:2:10:200
1143+12:2:10:1200
1144+1234:-3:10:NaN
11451234567890123:12:10:1234567890123000000000000
b3abae2a
JH
1146-3:1:2:-6
1147-5:1:2:-10
1148-2:1:2:-4
1149-102533203:1:2:-205066406
6854fd01
JH
1150&brsft
1151abc:abc:NaN
61f5c3f5
T
1152+8:+2:2
1153+4294967296:+32:1
1154+281474976710656:+48:1
6854fd01 1155+2:-2:NaN
a9ccbcd7 1156# exercise base 10
6854fd01 1157-1234:0:10:-1234
61f5c3f5 1158+1234:0:10:1234
6854fd01
JH
1159+200:2:10:2
1160+1234:3:10:1
1161+1234:2:10:12
1162+1234:-3:10:NaN
1163310000:4:10:31
116412300000:5:10:123
11651230000000000:10:10:123
116609876123456789067890:12:10:9876123
11671234561234567890123:13:10:123456
b3abae2a
JH
1168820265627:1:2:410132813
1169# test shifting negative numbers in base 2
1170-15:1:2:-8
1171-14:1:2:-7
1172-13:1:2:-7
1173-12:1:2:-6
1174-11:1:2:-6
1175-10:1:2:-5
1176-9:1:2:-5
1177-8:1:2:-4
1178-7:1:2:-4
1179-6:1:2:-3
1180-5:1:2:-3
1181-4:1:2:-2
1182-3:1:2:-2
1183-2:1:2:-1
1184-1:1:2:-1
1185-1640531254:2:2:-410132814
1186-1640531254:1:2:-820265627
1187-820265627:1:2:-410132814
1188-205066405:1:2:-102533203
6854fd01 1189&bsstr
56d9de68
T
1190+inf:inf
1191-inf:-inf
6854fd01
JH
11921e+34:1e+34
1193123.456E3:123456e+0
1194100:1e+2
56d9de68
T
1195bsstrabc:NaN
1196-5:-5e+0
1197-100:-1e+2
1198&numify
1199numifyabc:NaN
1200+inf:inf
1201-inf:-inf
12025:5
1203-5:-5
1204100:100
1205-100:-100
6854fd01
JH
1206&bneg
1207bnegNaN:NaN
1208+inf:-inf
1209-inf:inf
1210abd:NaN
61f5c3f5
T
12110:0
12121:-1
1213-1:1
6854fd01 1214+123456789:-123456789
61f5c3f5 1215-123456789:123456789
6854fd01
JH
1216&babs
1217babsNaN:NaN
1218+inf:inf
1219-inf:inf
61f5c3f5
T
12200:0
12211:1
1222-1:1
1223+123456789:123456789
1224-123456789:123456789
7833bfdd
PJA
1225&bsgn
1226NaN:NaN
1227+inf:1
1228-inf:-1
12290:0
1230+123456789:1
1231-123456789:-1
6854fd01
JH
1232&bcmp
1233bcmpNaN:bcmpNaN:
61f5c3f5
T
1234bcmpNaN:0:
12350:bcmpNaN:
12360:0:0
1237-1:0:-1
12380:-1:1
12391:0:1
12400:1:-1
1241-1:1:-1
12421:-1:1
6854fd01 1243-1:-1:0
61f5c3f5
T
12441:1:0
1245123:123:0
1246123:12:1
124712:123:-1
6854fd01
JH
1248-123:-123:0
1249-123:-12:-1
1250-12:-123:1
61f5c3f5
T
1251123:124:-1
1252124:123:1
6854fd01
JH
1253-123:-124:1
1254-124:-123:-1
61f5c3f5
T
1255100:5:1
1256-123456789:987654321:-1
6854fd01 1257+123456789:-987654321:1
61f5c3f5 1258-987654321:123456789:-1
6854fd01
JH
1259-inf:5432112345:-1
1260+inf:5432112345:1
1261-inf:-5432112345:-1
1262+inf:-5432112345:1
1263+inf:+inf:0
1264-inf:-inf:0
1265+inf:-inf:1
1266-inf:+inf:-1
12675:inf:-1
12685:inf:-1
1269-5:-inf:1
1270-5:-inf:1
1271# return undef
1272+inf:NaN:
1273NaN:inf:
1274-inf:NaN:
1275NaN:-inf:
1276&binc
1277abc:NaN
1278+inf:inf
1279-inf:-inf
61f5c3f5
T
1280+0:1
1281+1:2
1282-1:0
6854fd01
JH
1283&bdec
1284abc:NaN
1285+inf:inf
1286-inf:-inf
1287+0:-1
61f5c3f5 1288+1:0
6854fd01
JH
1289-1:-2
1290&badd
1291abc:abc:NaN
61f5c3f5 1292abc:0:NaN
6854fd01 1293+0:abc:NaN
b3abae2a
JH
1294+inf:-inf:NaN
1295-inf:+inf:NaN
6854fd01
JH
1296+inf:+inf:inf
1297-inf:-inf:-inf
1298baddNaN:+inf:NaN
1299baddNaN:+inf:NaN
1300+inf:baddNaN:NaN
1301-inf:baddNaN:NaN
61f5c3f5
T
13020:0:0
13031:0:1
13040:1:1
13051:1:2
1306-1:0:-1
13070:-1:-1
6854fd01 1308-1:-1:-2
61f5c3f5
T
1309-1:+1:0
1310+1:-1:0
1311+9:+1:10
1312+99:+1:100
1313+999:+1:1000
1314+9999:+1:10000
1315+99999:+1:100000
1316+999999:+1:1000000
1317+9999999:+1:10000000
1318+99999999:+1:100000000
1319+999999999:+1:1000000000
1320+9999999999:+1:10000000000
1321+99999999999:+1:100000000000
1322+10:-1:9
1323+100:-1:99
1324+1000:-1:999
1325+10000:-1:9999
1326+100000:-1:99999
1327+1000000:-1:999999
1328+10000000:-1:9999999
1329+100000000:-1:99999999
1330+1000000000:-1:999999999
1331+10000000000:-1:9999999999
1332+123456789:987654321:1111111110
1333-123456789:987654321:864197532
6854fd01
JH
1334-123456789:-987654321:-1111111110
1335+123456789:-987654321:-864197532
56b9c951
JH
1336-1:10001:10000
1337-1:100001:100000
1338-1:1000001:1000000
1339-1:10000001:10000000
1340-1:100000001:100000000
1341-1:1000000001:1000000000
1342-1:10000000001:10000000000
1343-1:100000000001:100000000000
1344-1:1000000000001:1000000000000
1345-1:10000000000001:10000000000000
1346-1:-10001:-10002
1347-1:-100001:-100002
1348-1:-1000001:-1000002
1349-1:-10000001:-10000002
1350-1:-100000001:-100000002
1351-1:-1000000001:-1000000002
1352-1:-10000000001:-10000000002
1353-1:-100000000001:-100000000002
1354-1:-1000000000001:-1000000000002
1355-1:-10000000000001:-10000000000002
6854fd01
JH
1356&bsub
1357abc:abc:NaN
1358abc:+0:NaN
1359+0:abc:NaN
1360+inf:-inf:inf
1361-inf:+inf:-inf
b3abae2a
JH
1362+inf:+inf:NaN
1363-inf:-inf:NaN
61f5c3f5
T
1364+0:+0:0
1365+1:+0:1
6854fd01 1366+0:+1:-1
61f5c3f5 1367+1:+1:0
6854fd01 1368-1:+0:-1
61f5c3f5
T
1369+0:-1:1
1370-1:-1:0
6854fd01 1371-1:+1:-2
61f5c3f5
T
1372+1:-1:2
1373+9:+1:8
1374+99:+1:98
1375+999:+1:998
1376+9999:+1:9998
1377+99999:+1:99998
1378+999999:+1:999998
1379+9999999:+1:9999998
1380+99999999:+1:99999998
1381+999999999:+1:999999998
1382+9999999999:+1:9999999998
1383+99999999999:+1:99999999998
1384+10:-1:11
1385+100:-1:101
1386+1000:-1:1001
1387+10000:-1:10001
1388+100000:-1:100001
1389+1000000:-1:1000001
1390+10000000:-1:10000001
1391+100000000:-1:100000001
1392+1000000000:-1:1000000001
1393+10000000000:-1:10000000001
6854fd01
JH
1394+123456789:+987654321:-864197532
1395-123456789:+987654321:-1111111110
61f5c3f5
T
1396-123456789:-987654321:864197532
1397+123456789:-987654321:1111111110
56b9c951
JH
139810001:1:10000
1399100001:1:100000
14001000001:1:1000000
140110000001:1:10000000
1402100000001:1:100000000
14031000000001:1:1000000000
140410000000001:1:10000000000
1405100000000001:1:100000000000
14061000000000001:1:1000000000000
140710000000000001:1:10000000000000
140810001:-1:10002
1409100001:-1:100002
14101000001:-1:1000002
141110000001:-1:10000002
1412100000001:-1:100000002
14131000000001:-1:1000000002
141410000000001:-1:10000000002
1415100000000001:-1:100000000002
14161000000000001:-1:1000000000002
141710000000000001:-1:10000000000002
80365507
T
1418&bmuladd
1419abc:abc:0:NaN
1420abc:+0:0:NaN
1421+0:abc:0:NaN
1422+0:0:abc:NaN
1423NaNmul:+inf:0:NaN
1424NaNmul:-inf:0:NaN
1425-inf:NaNmul:0:NaN
1426+inf:NaNmul:0:NaN
1427+inf:+inf:0:inf
1428+inf:-inf:0:-inf
1429-inf:+inf:0:-inf
1430-inf:-inf:0:inf
1431+0:+0:0:0
1432+0:+1:0:0
1433+1:+0:0:0
1434+0:-1:0:0
1435-1:+0:0:0
1436123456789123456789:0:0:0
14370:123456789123456789:0:0
1438-1:-1:0:1
1439-1:-1:0:1
1440-1:+1:0:-1
1441+1:-1:0:-1
1442+1:+1:0:1
1443+2:+3:0:6
1444-2:+3:0:-6
1445+2:-3:0:-6
1446-2:-3:0:6
1447111:111:0:12321
144810101:10101:0:102030201
14491001001:1001001:0:1002003002001
1450100010001:100010001:0:10002000300020001
145110000100001:10000100001:0:100002000030000200001
145211111111111:9:0:99999999999
145322222222222:9:0:199999999998
145433333333333:9:0:299999999997
145544444444444:9:0:399999999996
145655555555555:9:0:499999999995
145766666666666:9:0:599999999994
145877777777777:9:0:699999999993
145988888888888:9:0:799999999992
146099999999999:9:0:899999999991
146111111111111:9:1:100000000000
146222222222222:9:1:199999999999
146333333333333:9:1:299999999998
146444444444444:9:1:399999999997
146555555555555:9:1:499999999996
146666666666666:9:1:599999999995
146777777777777:9:1:699999999994
146888888888888:9:1:799999999993
146999999999999:9:1:899999999992
1470-3:-4:-5:7
14713:-4:-5:-17
1472-3:4:-5:-17
14733:4:-5:7
1474-3:4:5:-7
14753:-4:5:-7
14769999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
14772:3:12345678901234567890:12345678901234567896
6854fd01
JH
1478&bmul
1479abc:abc:NaN
1480abc:+0:NaN
1481+0:abc:NaN
1482NaNmul:+inf:NaN
1483NaNmul:-inf:NaN
1484-inf:NaNmul:NaN
1485+inf:NaNmul:NaN
1486+inf:+inf:inf
1487+inf:-inf:-inf
1488-inf:+inf:-inf
1489-inf:-inf:inf
61f5c3f5
T
1490+0:+0:0
1491+0:+1:0
1492+1:+0:0
1493+0:-1:0
1494-1:+0:0
1495123456789123456789:0:0
14960:123456789123456789:0
1497-1:-1:1
6854fd01
JH
1498-1:+1:-1
1499+1:-1:-1
61f5c3f5
T
1500+1:+1:1
1501+2:+3:6
6854fd01
JH
1502-2:+3:-6
1503+2:-3:-6
61f5c3f5
T
1504-2:-3:6
1505111:111:12321
150610101:10101:102030201
15071001001:1001001:1002003002001
1508100010001:100010001:10002000300020001
150910000100001:10000100001:100002000030000200001
151011111111111:9:99999999999
151122222222222:9:199999999998
151233333333333:9:299999999997
151344444444444:9:399999999996
151455555555555:9:499999999995
151566666666666:9:599999999994
151677777777777:9:699999999993
151788888888888:9:799999999992
151899999999999:9:899999999991
1519+25:+25:625
1520+12345:+12345:152399025
1521+99999:+11111:1111088889
6854fd01
JH
15229999:10000:99990000
152399999:100000:9999900000
1524999999:1000000:999999000000
15259999999:10000000:99999990000000
152699999999:100000000:9999999900000000
1527999999999:1000000000:999999999000000000
15289999999999:10000000000:99999999990000000000
152999999999999:100000000000:9999999999900000000000
1530999999999999:1000000000000:999999999999000000000000
15319999999999999:10000000000000:99999999999990000000000000
153299999999999999:100000000000000:9999999999999900000000000000
1533999999999999999:1000000000000000:999999999999999000000000000000
15349999999999999999:10000000000000000:99999999999999990000000000000000
153599999999999999999:100000000000000000:9999999999999999900000000000000000
1536999999999999999999:1000000000000000000:999999999999999999000000000000000000
15379999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1538&bdiv-list
1539100:20:5,0
15404095:4095:1,0
1541-4095:-4095:1,0
15424095:-4095:-1,0
1543-4095:4095:-1,0
1544123:2:61,1
b3abae2a
JH
15459:5:1,4
15469:4:2,1
6854fd01
JH
1547# inf handling and general remainder
15485:8:0,5
15490:8:0,0
155011:2:5,1
155111:-2:-5,-1
1552-11:2:-5,1
1553# see table in documentation in MBI
15540:inf:0,0
15550:-inf:0,0
15565:inf:0,5
15575:-inf:0,5
1558-5:inf:0,-5
1559-5:-inf:0,-5
1560inf:5:inf,0
1561-inf:5:-inf,0
1562inf:-5:-inf,0
1563-inf:-5:inf,0
15645:5:1,0
1565-5:-5:1,0
b3abae2a
JH
1566inf:inf:NaN,NaN
1567-inf:-inf:NaN,NaN
1568-inf:inf:NaN,NaN
1569inf:-inf:NaN,NaN
6854fd01
JH
15708:0:inf,8
1571inf:0:inf,inf
f603091d 1572# exceptions to remainder rule
6854fd01
JH
1573-8:0:-inf,-8
1574-inf:0:-inf,-inf
15750:0:NaN,NaN
990fb837
RGS
1576# test the shortcut in Calc if @$x == @$yorg
15771234567812345678:123456712345678:10,688888898
157812345671234567:1234561234567:10,58888897
1579123456123456:12345123456:10,4888896
15801234512345:123412345:10,388895
15811234567890999999999:1234567890:1000000000,999999999
15821234567890000000000:1234567890:1000000000,0
15831234567890999999999:9876543210:124999998,9503086419
15841234567890000000000:9876543210:124999998,8503086420
158596969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
7596a890
RGS
1586# bug in v1.76
15871267650600228229401496703205375:1267650600228229401496703205376:0,1267650600228229401496703205375
a9ccbcd7 1588# exercise shortcut for numbers of the same length in div
b68b7ab1
T
1589999999999999999999999999999999999:999999999999999999999999999999999:1,0
1590999999999999999999999999999999999:888888888888888888888888888888888:1,111111111111111111111111111111111
1591999999999999999999999999999999999:777777777777777777777777777777777:1,222222222222222222222222222222222
1592999999999999999999999999999999999:666666666666666666666666666666666:1,333333333333333333333333333333333
1593999999999999999999999999999999999:555555555555555555555555555555555:1,444444444444444444444444444444444
1594999999999999999999999999999999999:444444444444444444444444444444444:2,111111111111111111111111111111111
1595999999999999999999999999999999999:333333333333333333333333333333333:3,0
1596999999999999999999999999999999999:222222222222222222222222222222222:4,111111111111111111111111111111111
1597999999999999999999999999999999999:111111111111111111111111111111111:9,0
15989999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3,0
15999999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3,999999999999999999999
16009999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3,999999999999999999999999999
16019999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4,1999999999999999999999999999
16029999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9,999999999999999999999999999
16039999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99,99999999999999999999999999
16049999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999,9999999999999999999999999
16059999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999,999999999999999999999999
16069999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999,99999999999999999999999
16079999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999,9999999999999999999999
16089999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999,999999999999999999999
6854fd01
JH
1609&bdiv
1610abc:abc:NaN
61f5c3f5
T
1611abc:1:NaN
16121:abc:NaN
16130:0:NaN
6854fd01
JH
1614# inf handling (see table in doc)
16150:inf:0
16160:-inf:0
16175:inf:0
16185:-inf:0
1619-5:inf:0
1620-5:-inf:0
1621inf:5:inf
1622-inf:5:-inf
1623inf:-5:-inf
1624-inf:-5:inf
16255:5:1
1626-5:-5:1
b3abae2a
JH
1627inf:inf:NaN
1628-inf:-inf:NaN
1629-inf:inf:NaN
1630inf:-inf:NaN
6854fd01
JH
16318:0:inf
1632inf:0:inf
1633-8:0:-inf
1634-inf:0:-inf
16350:0:NaN
163611:2:5
1637-11:-2:5
1638-11:2:-5
163911:-2:-5
61f5c3f5
T
16400:1:0
16410:-1:0
16421:1:1
1643-1:-1:1
16441:-1:-1
1645-1:1:-1
16461:2:0
16472:1:2
16481:26:0
16491000000000:9:111111111
16502000000000:9:222222222
16513000000000:9:333333333
16524000000000:9:444444444
16535000000000:9:555555555
16546000000000:9:666666666
16557000000000:9:777777777
16568000000000:9:888888888
16579000000000:9:1000000000
165835500000:113:314159
165971000000:226:314159
1660106500000:339:314159
16611000000000:3:333333333
1662+10:+5:2
1663+100:+4:25
1664+1000:+8:125
1665+10000:+16:625
1666999999999999:9:111111111111
1667999999999999:99:10101010101
1668999999999999:999:1001001001
1669999999999999:9999:100010001
1670999999999999999:99999:10000100001
1671+1111088889:99999:11111
6854fd01
JH
1672-5:-3:1
1673-5:3:-1
16744:3:1
16754:-3:-1
16761:3:0
16771:-3:0
1678-2:-3:0
1679-2:3:0
16808:3:2
1681-8:3:-2
168214:-3:-4
1683-14:3:-4
1684-14:-3:4
168514:3:4
1686# bug in Calc with '99999' vs $BASE-1
168710000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
990fb837
RGS
1688# test the shortcut in Calc if @$x == @$yorg
16891234567812345678:123456712345678:10
169012345671234567:1234561234567:10
1691123456123456:12345123456:10
16921234512345:123412345:10
16931234567890999999999:1234567890:1000000000
16941234567890000000000:1234567890:1000000000
16951234567890999999999:9876543210:124999998
16961234567890000000000:9876543210:124999998
169796969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
aef458a0
JH
1698# bug up to v0.35 in Calc (--$q one too many)
169984696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
170084696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
170184696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
170284696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
c4a6f826 1703# exercise shortcut for numbers of the same length in div
b68b7ab1
T
1704999999999999999999999999999999999:999999999999999999999999999999999:1
1705999999999999999999999999999999999:888888888888888888888888888888888:1
1706999999999999999999999999999999999:777777777777777777777777777777777:1
1707999999999999999999999999999999999:666666666666666666666666666666666:1
1708999999999999999999999999999999999:555555555555555555555555555555555:1
1709999999999999999999999999999999999:444444444444444444444444444444444:2
1710999999999999999999999999999999999:333333333333333333333333333333333:3
1711999999999999999999999999999999999:222222222222222222222222222222222:4
1712999999999999999999999999999999999:111111111111111111111111111111111:9
17139999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3
17149999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3
17159999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3
17169999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4
17179999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9
17189999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99
17199999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999
17209999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999
17219999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999
17229999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999
17239999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999
a87115f0
RGS
1724# bug with shortcut in Calc 0.44
1725949418181818187070707070707070707070:181818181853535353535353535353535353:5
07d34614
T
1726&bmodinv
1727# format: number:modulus:result
1728# bmodinv Data errors
1729abc:abc:NaN
1730abc:5:NaN
17315:abc:NaN
1732# bmodinv Expected Results from normal use
17331:5:1
17343:5:2
487de07a 17353:-5:-3
07d34614
T
1736-2:5:2
17378:5033:4404
56d9de68
T
17381234567891:13:6
1739-1234567891:13:7
07d34614 1740324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
116f6d6b
PJA
1741-2:1:0
1742-1:1:0
17430:1:0
17441:1:0
17452:1:0
17463:1:0
17474:1:0
1748-2:3:1
1749-1:3:2
17500:3:NaN
17511:3:1
17522:3:2
17533:3:NaN
17544:3:1
1755-2:4:NaN
1756-1:4:3
17570:4:NaN
17581:4:1
17592:4:NaN
17603:4:3
17614:4:NaN
d614cd8b 1762## bmodinv Error cases / useless use of function
07d34614 1763inf:5:NaN
1ddff52a
JH
17645:inf:NaN
1765-inf:5:NaN
17665:-inf:NaN
07d34614
T
1767&bmodpow
1768# format: number:exponent:modulus:result
1769# bmodpow Data errors
1770abc:abc:abc:NaN
17715:abc:abc:NaN
1772abc:5:abc:NaN
1773abc:abc:5:NaN
17745:5:abc:NaN
17755:abc:5:NaN
1776abc:5:5:NaN
3a7a056a 17773:5:0:NaN
07d34614
T
1778# bmodpow Expected results
17790:0:2:1
17801:0:2:1
3a7a056a 17810:3:5:0
116f6d6b
PJA
1782-2:-2:1:0
1783-1:-2:1:0
17840:-2:1:0
17851:-2:1:0
17862:-2:1:0
17873:-2:1:0
17884:-2:1:0
1789-2:-1:1:0
1790-1:-1:1:0
17910:-1:1:0
17921:-1:1:0
17932:-1:1:0
17943:-1:1:0
17954:-1:1:0
1796-2:0:1:0
1797-1:0:1:0
17980:0:1:0
17991:0:1:0
18002:0:1:0
18013:0:1:0
18024:0:1:0
1803-2:1:1:0
1804-1:1:1:0
18050:1:1:0
18061:1:1:0
18072:1:1:0
18083:1:1:0
18094:1:1:0
1810-2:2:1:0
1811-1:2:1:0
18120:2:1:0
18131:2:1:0
18142:2:1:0
18153:2:1:0
18164:2:1:0
1817-2:3:1:0
1818-1:3:1:0
18190:3:1:0
18201:3:1:0
18212:3:1:0
18223:3:1:0
18234:3:1:0
1824-2:4:1:0
1825-1:4:1:0
18260:4:1:0
18271:4:1:0
18282:4:1:0
18293:4:1:0
18304:4:1:0
1831-2:-2:3:1
1832-1:-2:3:1
18330:-2:3:NaN
18341:-2:3:1
18352:-2:3:1
18363:-2:3:NaN
18374:-2:3:1
1838-2:-1:3:1
1839-1:-1:3:2
18400:-1:3:NaN
18411:-1:3:1
18422:-1:3:2
18433:-1:3:NaN
18444:-1:3:1
1845-2:0:3:1
1846-1:0:3:1
18470:0:3:1
18481:0:3:1
18492:0:3:1
18503:0:3:1
18514:0:3:1
1852-2:1:3:1
1853-1:1:3:2
18540:1:3:0
18551:1:3:1
18562:1:3:2
18573:1:3:0
18584:1:3:1
1859-2:2:3:1
1860-1:2:3:1
18610:2:3:0
18621:2:3:1
18632:2:3:1
18643:2:3:0
18654:2:3:1
1866-2:3:3:1
1867-1:3:3:2
18680:3:3:0
18691:3:3:1
18702:3:3:2
18713:3:3:0
18724:3:3:1
1873-2:4:3:1
1874-1:4:3:1
18750:4:3:0
18761:4:3:1
18772:4:3:1
18783:4:3:0
18794:4:3:1
1880-2:-2:4:NaN
1881-1:-2:4:1
18820:-2:4:NaN
18831:-2:4:1
18842:-2:4:NaN
18853:-2:4:1
18864:-2:4:NaN
1887-2:-1:4:NaN
1888-1:-1:4:3
18890:-1:4:NaN
18901:-1:4:1
18912:-1:4:NaN
18923:-1:4:3
18934:-1:4:NaN
1894-2:0:4:1
1895-1:0:4:1
18960:0:4:1
18971:0:4:1
18982:0:4:1
18993:0:4:1
19004:0:4:1
1901-2:1:4:2
1902-1:1:4:3
19030:1:4:0
19041:1:4:1
19052:1:4:2
19063:1:4:3
19074:1:4:0
1908-2:2:4:0
1909-1:2:4:1
19100:2:4:0
19111:2:4:1
19122:2:4:0
19133:2:4:1
19144:2:4:0
1915-2:3:4:0
1916-1:3:4:3
19170:3:4:0
19181:3:4:1
19192:3:4:0
19203:3:4:3
19214:3:4:0
1922-2:4:4:0
1923-1:4:4:1
19240:4:4:0
19251:4:4:1
19262:4:4:0
19273:4:4:1
19284:4:4:0
19298:-1:16:NaN
07d34614 19308:-1:5033:4404
116f6d6b
PJA
19318:7:5032:3840
19328:8:-5:-4
ddb27680 19331e50:1:1:0
07d34614
T
193498436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1935# bmodpow Error cases
07d34614
T
1936inf:5:13:NaN
19375:inf:13:NaN
6854fd01
JH
1938&bmod
1939# inf handling, see table in doc
19400:inf:0
19410:-inf:0
19425:inf:5
19435:-inf:5
1944-5:inf:-5
1945-5:-inf:-5
1946inf:5:0
1947-inf:5:0
1948inf:-5:0
1949-inf:-5:0
19505:5:0
1951-5:-5:0
b3abae2a
JH
1952inf:inf:NaN
1953-inf:-inf:NaN
1954-inf:inf:NaN
1955inf:-inf:NaN
6854fd01
JH
19568:0:8
1957inf:0:inf
f603091d 1958# exceptions to remainder rule
6854fd01
JH
1959-inf:0:-inf
1960-8:0:-8
19610:0:NaN
1962abc:abc:NaN
61f5c3f5
T
1963abc:1:abc:NaN
19641:abc:NaN
19650:0:NaN
19660:1:0
19671:0:1
19680:-1:0
1969-1:0:-1
19701:1:0
1971-1:-1:0
19721:-1:0
1973-1:1:0
19741:2:1
19752:1:0
19761000000000:9:1
19772000000000:9:2
19783000000000:9:3
19794000000000:9:4
19805000000000:9:5
19816000000000:9:6
19827000000000:9:7
19838000000000:9:8
19849000000000:9:0
198535500000:113:33
198671000000:226:66
1987106500000:339:99
19881000000000:3:1
198910:5:0
1990100:4:0
19911000:8:0
199210000:16:0
1993999999999999:9:0
1994999999999999:99:0
1995999999999999:999:0
1996999999999999:9999:0
1997999999999999999:99999:0
1998-9:+5:1
6854fd01
JH
1999+9:-5:-1
2000-9:-5:-4
2001-5:3:1
2002-2:3:1
20034:3:1
20041:3:1
2005-5:-3:-2
2006-2:-3:-2
20074:-3:-2
20081:-3:-2
20094095:4095:0
027dc388
JH
2010100041000510123:3:0
2011152403346:12345:4321
b3abae2a 20129:5:4
28df3e88
JH
2013# test shortcuts in Calc
2014# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
20151234:9:1
2016123456:9:3
201712345678:9:0
20181234567891:9:1
2019123456789123:9:6
202012345678912345:9:6
20211234567891234567:9:1
2022123456789123456789:9:0
20231234:10:4
2024123456:10:6
202512345678:10:8
20261234567891:10:1
2027123456789123:10:3
202812345678912345:10:5
20291234567891234567:10:7
2030123456789123456789:10:9
20311234:113:104
2032123456:113:60
203312345678:113:89
20341234567891:113:64
2035123456789123:113:95
203612345678912345:113:53
20371234567891234567:113:56
2038123456789123456789:113:39
07d34614
T
2039# bug in bmod() not modifying the variable in place
2040-629:5033:4404
aef458a0
JH
2041# bug in bmod() in Calc in the _div_use_div() shortcut code path,
2042# when X == X and X was big
2043111111111111111111111111111111:111111111111111111111111111111:0
204412345678901234567890:12345678901234567890:0
6854fd01 2045&bgcd
9b924220
RGS
2046inf:12:NaN
2047-inf:12:NaN
204812:inf:NaN
204912:-inf:NaN
2050inf:inf:NaN
2051inf:-inf:NaN
2052-inf:-inf:NaN
6854fd01
JH
2053abc:abc:NaN
2054abc:+0:NaN
2055+0:abc:NaN
61f5c3f5
T
2056+0:+0:0
2057+0:+1:1
2058+1:+0:1
2059+1:+1:1
2060+2:+3:1
2061+3:+2:1
2062-3:+2:1
9b924220
RGS
2063-3:-2:1
2064-144:-60:12
2065144:-60:12
2066144:60:12
61f5c3f5
T
2067100:625:25
20684096:81:1
20691034:804:2
207027:90:56:1
207127:90:54:9
6854fd01
JH
2072&blcm
2073abc:abc:NaN
2074abc:+0:NaN
2075+0:abc:NaN
2076+0:+0:NaN
61f5c3f5
T
2077+1:+0:0
2078+0:+1:0
2079+27:+90:270
2080+1034:+804:415668
6854fd01
JH
2081&band
2082abc:abc:NaN
2083abc:0:NaN
20840:abc:NaN
20851:2:0
20863:2:2
61f5c3f5
T
2087+8:+2:0
2088+281474976710656:0:0
2089+281474976710656:1:0
2090+281474976710656:+281474976710656:281474976710656
9b924220 2091281474976710656:-1:281474976710656
6854fd01
JH
2092-2:-3:-4
2093-1:-1:-1
2094-6:-6:-6
2095-7:-4:-8
2096-7:4:0
2097-4:7:4
9b924220
RGS
2098# negative argument is bitwise shorter than positive [perl #26559]
209930:-3:28
2100123:-1:123
394e6ffb
JH
2101# equal arguments are treated special, so also do some test with unequal ones
21020xFFFF:0xFFFF:0x0xFFFF
21030xFFFFFF:0xFFFFFF:0x0xFFFFFF
21040xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
21050xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21060xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21070xF0F0:0xF0F0:0x0xF0F0
21080x0F0F:0x0F0F:0x0x0F0F
21090xF0F0F0:0xF0F0F0:0x0xF0F0F0
21100x0F0F0F:0x0F0F0F:0x0x0F0F0F
21110xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
21120x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
21130xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
21140x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
21150xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
21160x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
21170x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01
JH
2118&bior
2119abc:abc:NaN
2120abc:0:NaN
21210:abc:NaN
21221:2:3
61f5c3f5
T
2123+8:+2:10
2124+281474976710656:0:281474976710656
2125+281474976710656:1:281474976710657
2126+281474976710656:281474976710656:281474976710656
6854fd01
JH
2127-2:-3:-1
2128-1:-1:-1
2129-6:-6:-6
2130-7:4:-3
2131-4:7:-1
9b924220
RGS
2132+281474976710656:-1:-1
213330:-3:-1
213430:-4:-2
2135300:-76:-68
2136-76:300:-68
394e6ffb
JH
2137# equal arguments are treated special, so also do some test with unequal ones
21380xFFFF:0xFFFF:0x0xFFFF
21390xFFFFFF:0xFFFFFF:0x0xFFFFFF
21400xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
21410xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21420xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21430:0xFFFF:0x0xFFFF
21440:0xFFFFFF:0x0xFFFFFF
21450:0xFFFFFFFF:0x0xFFFFFFFF
21460:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21470:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21480xFFFF:0:0x0xFFFF
21490xFFFFFF:0:0x0xFFFFFF
21500xFFFFFFFF:0:0x0xFFFFFFFF
21510xFFFFFFFFFF:0:0x0xFFFFFFFFFF
21520xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
21530xF0F0:0xF0F0:0x0xF0F0
21540x0F0F:0x0F0F:0x0x0F0F
21550xF0F0:0x0F0F:0x0xFFFF
21560xF0F0F0:0xF0F0F0:0x0xF0F0F0
21570x0F0F0F:0x0F0F0F:0x0x0F0F0F
21580x0F0F0F:0xF0F0F0:0x0xFFFFFF
21590xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
21600x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
21610x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
21620xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
21630x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
21640x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
21650xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
21660x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
21670x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
21680x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01
JH
2169&bxor
2170abc:abc:NaN
2171abc:0:NaN
21720:abc:NaN
21731:2:3
61f5c3f5
T
2174+8:+2:10
2175+281474976710656:0:281474976710656
2176+281474976710656:1:281474976710657
2177+281474976710656:281474976710656:0
6854fd01
JH
2178-2:-3:3
2179-1:-1:0
2180-6:-6:0
2181-7:4:-3
2182-4:7:-5
21834:-7:-3
2184-4:-7:5
9b924220
RGS
218530:-3:-29
218630:-4:-30
2187300:-76:-360
2188-76:300:-360
394e6ffb
JH
2189# equal arguments are treated special, so also do some test with unequal ones
21900xFFFF:0xFFFF:0
21910xFFFFFF:0xFFFFFF:0
21920xFFFFFFFF:0xFFFFFFFF:0
21930xFFFFFFFFFF:0xFFFFFFFFFF:0
21940xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
21950:0xFFFF:0x0xFFFF
21960:0xFFFFFF:0x0xFFFFFF
21970:0xFFFFFFFF:0x0xFFFFFFFF
21980:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21990:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
22000xFFFF:0:0x0xFFFF
22010xFFFFFF:0:0x0xFFFFFF
22020xFFFFFFFF:0:0x0xFFFFFFFF
22030xFFFFFFFFFF:0:0x0xFFFFFFFFFF
22040xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
22050xF0F0:0xF0F0:0
22060x0F0F:0x0F0F:0
22070xF0F0:0x0F0F:0x0xFFFF
22080xF0F0F0:0xF0F0F0:0
22090x0F0F0F:0x0F0F0F:0
22100x0F0F0F:0xF0F0F0:0x0xFFFFFF
22110xF0F0F0F0:0xF0F0F0F0:0
22120x0F0F0F0F:0x0F0F0F0F:0
22130x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
22140xF0F0F0F0F0:0xF0F0F0F0F0:0
22150x0F0F0F0F0F:0x0F0F0F0F0F:0
22160x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
22170xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
22180x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
22190x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01
JH
2220&bnot
2221abc:NaN
2222+0:-1
2223+8:-9
2224+281474976710656:-281474976710657
2225-1:0
2226-2:1
2227-12:11
2228&digit
22290:0:0
223012:0:2
223112:1:1
2232123:0:3
2233123:1:2
2234123:2:1
2235123:-1:1
2236123:-2:2
2237123:-3:3
2238123456:0:6
2239123456:1:5
2240123456:2:4
2241123456:3:3
2242123456:4:2
2243123456:5:1
2244123456:-1:1
2245123456:-2:2
2246123456:-3:3
2247100000:-3:0
2248100000:0:0
2249100000:1:0
2250&mantissa
2251abc:NaN
22521e4:1
22532e0:2
2254123:123
2255-1:-1
2256-2:-2
2257+inf:inf
2258-inf:-inf
2259&exponent
2260abc:NaN
22611e4:4
22622e0:0
2263123:0
2264-1:0
2265-2:0
22660:1
2267+inf:inf
2268-inf:inf
2269&parts
2270abc:NaN,NaN
22711e4:1,4
22722e0:2,0
2273123:123,0
2274-1:-1,0
2275-2:-2,0
22760:0,1
2277+inf:inf,inf
2278-inf:-inf,inf
b3abae2a
JH
2279&bfac
2280-1:NaN
2281NaNfac:NaN
b282a552 2282+inf:inf
b3abae2a
JH
2283-inf:NaN
22840:1
22851:1
22862:2
22873:6
22884:24
22895:120
22906:720
990fb837
RGS
22917:5040
22928:40320
22939:362880
b3abae2a
JH
229410:3628800
229511:39916800
229612:479001600
50109ad0
RGS
229720:2432902008176640000
229822:1124000727777607680000
229969:171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
6854fd01
JH
2300&bpow
2301abc:12:NaN
230212:abc:NaN
23030:0:1
23040:1:0
23050:2:0
9b924220
RGS
23060:-1:inf
23070:-2:inf
6854fd01
JH
23081:0:1
23091:1:1
23101:2:1
23111:3:1
23121:-1:1
23131:-2:1
23141:-3:1
23152:0:1
23162:1:2
23172:2:4
23182:3:8
23193:3:27
2d2b2744
T
2320-2:2:4
2321-2:3:-8
2322-2:4:16
2323-2:5:-32
6854fd01
JH
23242:-1:NaN
2325-2:-1:NaN
23262:-2:NaN
2327-2:-2:NaN
2d2b2744 2328# inf tests
6854fd01 2329+inf:1234500012:inf
2d2b2744
T
2330-inf:1234500012:inf
2331-inf:1234500013:-inf
6854fd01
JH
2332+inf:-12345000123:inf
2333-inf:-12345000123:-inf
2d2b2744
T
2334# -inf * -inf = inf
2335-inf:2:inf
2336-inf:0:NaN
2337-inf:-1:0
2338-inf:inf:NaN
23392:inf:inf
23402:-inf:0
23410:inf:0
23420:-inf:inf
2343-1:-inf:NaN
2344-1:inf:NaN
2345-2:inf:NaN
2346-2:-inf:0
2347NaN:inf:NaN
2348NaN:-inf:NaN
2349-inf:NaN:NaN
2350inf:NaN:NaN
2351inf:-inf:NaN
23521:inf:1
23531:-inf:1
6854fd01
JH
2354# 1 ** -x => 1 / (1 ** x)
2355-1:0:1
2356-2:0:1
2357-1:1:-1
2358-1:2:1
2359-1:3:-1
2360-1:4:1
2361-1:5:-1
2362-1:-1:-1
2363-1:-2:1
2364-1:-3:-1
2365-1:-4:1
236610:2:100
236710:3:1000
236810:4:10000
236910:5:100000
237010:6:1000000
237110:7:10000000
237210:8:100000000
237310:9:1000000000
237410:20:100000000000000000000
2375123456:2:15241383936
9b924220
RGS
2376-2:2:4
2377-2:3:-8
2378-2:4:16
2379-2:5:-32
2380-3:2:9
2381-3:3:-27
2382-3:4:81
2383-3:5:-243
6854fd01
JH
2384&length
2385100:3
238610:2
23871:1
23880:1
238912345:5
239010000000000000000:17
2391-123:3
2392215960156869840440586892398248:30
990fb837
RGS
2393&broot
2394# sqrt()
2395+0:2:0
2396+1:2:1
2397-1:2:NaN
2398# -$x ** (1/2) => -$y, but not in froot()
2399-123:2:NaN
2400+inf:2:inf
2401-inf:2:NaN
24022:2:1
2403-2:2:NaN
24044:2:2
24059:2:3
240616:2:4
2407100:2:10
2408123:2:11
240915241:2:123
2410144:2:12
241112:2:3
24120.49:2:0
24130.0049:2:0
2414# invalid ones
24151:NaN:NaN
2416-1:NaN:NaN
24170:NaN:NaN
2418-inf:NaN:NaN
2419+inf:NaN:NaN
2420NaN:0:NaN
2421NaN:2:NaN
2422NaN:inf:NaN
2423NaN:inf:NaN
242412:-inf:NaN
242512:inf:NaN
2426+0:0:NaN
2427+1:0:NaN
2428-1:0:NaN
2429-2:0:NaN
2430-123.45:0:NaN
2431+inf:0:NaN
243212:1:12
2433-12:1:NaN
24348:-1:NaN
2435-8:-1:NaN
2436# cubic root
24378:3:2
2438-8:3:NaN
2439# fourths root
c38b2de2
JH
244016:4:2
244181:4:3
3a427a11 2442# 2 ** 64
c38b2de2
JH
244318446744073709551616:4:65536
244418446744073709551616:8:256
244518446744073709551616:16:16
244618446744073709551616:32:4
244718446744073709551616:64:2
244818446744073709551616:128:1
3a427a11
RGS
2449# 213 ** 15
245084274086103068221283760416414557757:15:213
50109ad0 2451# see t/bigroot.t for more tests
6854fd01 2452&bsqrt
394e6ffb 2453145:12
6854fd01 2454144:12
394e6ffb 2455143:11
6854fd01 245616:4
394e6ffb
JH
2457170:13
2458169:13
2459168:12
6854fd01 24604:2
394e6ffb 24613:1
6854fd01 24622:1
394e6ffb 24639:3
6854fd01
JH
246412:3
2465256:16
2466100000000:10000
24674000000000000:2000000
394e6ffb
JH
2468152399026:12345
2469152399025:12345
2470152399024:12344
3a427a11
RGS
2471# 2 ** 64 => 2 ** 32
247218446744073709551616:4294967296
247384274086103068221283760416414557757:290299993288095377
6854fd01
JH
24741:1
24750:0
2476-2:NaN
394e6ffb 2477-123:NaN
6854fd01 2478Nan:NaN
990fb837
RGS
2479+inf:inf
2480-inf:NaN
50109ad0
RGS
2481# see t/biglog.t for more tests
2482&bexp
2483NaN:NaN
2484inf:inf
24851:2
24862:7
30afc38d
T
2487&batan2
2488NaN:1:10:NaN
2489NaN:NaN:10:NaN
24901:NaN:10:NaN
2491inf:1:14:1
2492-inf:1:14:-1
0dceeee6
RGS
24930:-inf:14:3
2494-1:-inf:14:-3
24951:-inf:14:3
24960:inf:14:0
2497inf:-inf:14:2
2498-inf:-inf:14:-2
2499# +- 0.78....
2500inf:+inf:14:0
2501-inf:+inf:14:0
30afc38d
T
25021:5:13:0
25031:5:14:0
25040:0:10:0
25050:1:14:0
25060:2:14:0
25071:0:14:1
25085:0:14:1
2509-1:0:11:-1
2510-2:0:77:-1
25112:0:77:1
2512-1:5:14:0
25131:5:14:0
2514-1:8:14:0
25151:8:14:0
2516-1:1:14:0
fdb4b05f
T
2517&bpi
251877:3
2519+0:3
252011:3
50109ad0
RGS
2521# see t/bignok.t for more tests
2522&bnok
2523+inf:10:inf
2524NaN:NaN:NaN
2525NaN:1:NaN
25261:NaN:NaN
25271:1:1
2528# k > n
25291:2:0
25302:3:0
2531# k < 0
25321:-2:0
2533# 7 over 3 = 35
25347:3:35
d5735945 25357:6:7
50109ad0
RGS
2536100:90:17310309456440
2537100:95:75287520
d5735945
PF
25382:0:1
25397:0:1
25402:1:2
6854fd01
JH
2541&bround
2542$round_mode('trunc')
25430:12:0
2544NaNbround:12:NaN
2545+inf:12:inf
2546-inf:12:-inf
25471234:0:1234
25481234:2:1200
2549123456:4:123400
2550123456:5:123450
2551123456:6:123456
61f5c3f5 2552+10123456789:5:10123000000
6854fd01 2553-10123456789:5:-10123000000
61f5c3f5 2554+10123456789:9:10123456700
6854fd01 2555-10123456789:9:-10123456700
61f5c3f5 2556+101234500:6:101234000
6854fd01 2557-101234500:6:-101234000
61f5c3f5 2558#+101234500:-4:101234000
6854fd01
JH
2559#-101234500:-4:-101234000
2560$round_mode('zero')
61f5c3f5 2561+20123456789:5:20123000000
6854fd01 2562-20123456789:5:-20123000000
61f5c3f5 2563+20123456789:9:20123456800
6854fd01 2564-20123456789:9:-20123456800
61f5c3f5 2565+201234500:6:201234000
6854fd01 2566-201234500:6:-201234000
61f5c3f5 2567#+201234500:-4:201234000
6854fd01
JH
2568#-201234500:-4:-201234000
2569+12345000:4:12340000
2570-12345000:4:-12340000
2571$round_mode('+inf')
61f5c3f5 2572+30123456789:5:30123000000
6854fd01 2573-30123456789:5:-30123000000
61f5c3f5 2574+30123456789:9:30123456800
6854fd01 2575-30123456789:9:-30123456800
61f5c3f5 2576+301234500:6:301235000
6854fd01 2577-301234500:6:-301234000
61f5c3f5 2578#+301234500:-4:301235000
6854fd01
JH
2579#-301234500:-4:-301234000
2580+12345000:4:12350000
2581-12345000:4:-12340000
2582$round_mode('-inf')
61f5c3f5 2583+40123456789:5:40123000000
6854fd01 2584-40123456789:5:-40123000000
61f5c3f5 2585+40123456789:9:40123456800
6854fd01 2586-40123456789:9:-40123456800
61f5c3f5
T
2587+401234500:6:401234000
2588+401234500:6:401234000
6854fd01
JH
2589#-401234500:-4:-401235000
2590#-401234500:-4:-401235000
2591+12345000:4:12340000
2592-12345000:4:-12350000
2593$round_mode('odd')
61f5c3f5 2594+50123456789:5:50123000000
6854fd01 2595-50123456789:5:-50123000000
61f5c3f5 2596+50123456789:9:50123456800
6854fd01 2597-50123456789:9:-50123456800
61f5c3f5 2598+501234500:6:501235000
6854fd01 2599-501234500:6:-501235000
61f5c3f5 2600#+501234500:-4:501235000
6854fd01
JH
2601#-501234500:-4:-501235000
2602+12345000:4:12350000
2603-12345000:4:-12350000
2604$round_mode('even')
61f5c3f5 2605+60123456789:5:60123000000
6854fd01 2606-60123456789:5:-60123000000
61f5c3f5 2607+60123456789:9:60123456800
6854fd01 2608-60123456789:9:-60123456800
61f5c3f5 2609+601234500:6:601234000
6854fd01 2610-601234500:6:-601234000
61f5c3f5 2611#+601234500:-4:601234000
6854fd01
JH
2612#-601234500:-4:-601234000
2613#-601234500:-9:0
2614#-501234500:-9:0
2615#-601234500:-8:0
2616#-501234500:-8:0
2617+1234567:7:1234567
2618+1234567:6:1234570
2619+12345000:4:12340000
2620-12345000:4:-12340000
7b29e1e6
T
2621$round_mode('common')
2622+60123456789:5:60123000000
2623+60123199999:5:60123000000
2624+60123299999:5:60123000000
2625+60123399999:5:60123000000
2626+60123499999:5:60123000000
2627+60123500000:5:60124000000
2628+60123600000:5:60124000000
2629+60123700000:5:60124000000
2630+60123800000:5:60124000000
2631+60123900000:5:60124000000
2632-60123456789:5:-60123000000
2633-60123199999:5:-60123000000
2634-60123299999:5:-60123000000
2635-60123399999:5:-60123000000
2636-60123499999:5:-60123000000
2637-60123500000:5:-60124000000
2638-60123600000:5:-60124000000
2639-60123700000:5:-60124000000
2640-60123800000:5:-60124000000
2641-60123900000:5:-60124000000
6854fd01
JH
2642&is_zero
26430:1
2644NaNzero:0
2645+inf:0
2646-inf:0
2647123:0
2648-1:0
26491:0
2650&is_one
26510:0
2652NaNone:0
2653+inf:0
2654-inf:0
26551:1
26562:0
2657-1:0
2658-2:0
6358232b 2659# floor, ceil, and int are pretty pointless in integer space, but play safe
6854fd01
JH
2660&bfloor
26610:0
2662NaNfloor:NaN
2663+inf:inf
2664-inf:-inf
2665-1:-1
2666-2:-2
26672:2
26683:3
2669abc:NaN
2670&bceil
2671NaNceil:NaN
2672+inf:inf
2673-inf:-inf
26740:0
2675-1:-1
2676-2:-2
26772:2
26783:3
2679abc:NaN
6358232b
PJA
2680&bint
2681NaN:NaN
2682+inf:inf
2683-inf:-inf
26840:0
2685-1:-1
2686-2:-2
26872:2
26883:3
6854fd01
JH
2689&as_hex
2690128:0x80
2691-128:-0x80
26920:0x0
2693-0:0x0
26941:0x1
26950x123456789123456789:0x123456789123456789
2696+inf:inf
2697-inf:-inf
2698NaNas_hex:NaN
2699&as_bin
2700128:0b10000000
2701-128:-0b10000000
27020:0b0
2703-0:0b0
27041:0b1
27050b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1ddff52a 27060x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001
6854fd01
JH
2707+inf:inf
2708-inf:-inf
2709NaNas_bin:NaN