Re: [perl #24774] eval + format - \n = pp_ctl.c assertion
[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);";
091c87b1 159 }elsif ($f eq "blog"){
160 $try .= "\$x->blog(\$y);";
6854fd01 161 }elsif ($f eq "band"){
162 $try .= "\$x & \$y;";
163 }elsif ($f eq "bior"){
164 $try .= "\$x | \$y;";
165 }elsif ($f eq "bxor"){
166 $try .= "\$x ^ \$y;";
167 }elsif ($f eq "bpow"){
168 $try .= "\$x ** \$y;";
d614cd8b 169 } elsif( $f eq "bmodinv") {
170 $try .= "\$x->bmodinv(\$y);";
6854fd01 171 }elsif ($f eq "digit"){
56b9c951 172 $try .= "\$x->digit(\$y);";
d614cd8b 173 } else {
174 $try .= "\$z = $class->new(\"$args[2]\");";
175
176 # Functions with three arguments
177 if( $f eq "bmodpow") {
178 $try .= "\$x->bmodpow(\$y,\$z);";
179 } else { warn "Unknown op '$f'"; }
180 }
61f5c3f5 181 } # end else all other ops
182
183 $ans1 = eval $try;
184 # convert hex/binary targets to decimal
185 if ($ans =~ /^(0x0x|0b0b)/)
186 {
187 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 188 }
61f5c3f5 189 if ($ans eq "")
190 {
191 ok_undef ($ans1);
192 }
193 else
194 {
195 # print "try: $try ans: $ans1 $ans\n";
196 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
b3abae2a 197 ok (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 198 }
61f5c3f5 199 # check internal state of number objects
200 is_valid($ans1,$f) if ref $ans1;
6854fd01 201 } # endwhile data tests
202close DATA;
203
204# test some more
205@a = ();
206for (my $i = 1; $i < 10; $i++)
207 {
208 push @a, $i;
209 }
210ok "@a", "1 2 3 4 5 6 7 8 9";
211
212# test whether self-multiplication works correctly (result is 2**64)
213$try = "\$x = $class->new('4294967296');";
214$try .= '$a = $x->bmul($x);';
215$ans1 = eval $try;
216print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64);
217# test self-pow
218$try = "\$x = $class->new(10);";
219$try .= '$a = $x->bpow($x);';
220$ans1 = eval $try;
221print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10);
222
07d34614 223###############################################################################
6854fd01 224# test whether op destroys args or not (should better not)
225
226$x = $class->new(3);
227$y = $class->new(4);
228$z = $x & $y;
229ok ($x,3);
230ok ($y,4);
231ok ($z,0);
232$z = $x | $y;
233ok ($x,3);
234ok ($y,4);
235ok ($z,7);
236$x = $class->new(1);
237$y = $class->new(2);
238$z = $x | $y;
239ok ($x,1);
240ok ($y,2);
241ok ($z,3);
242
243$x = $class->new(5);
244$y = $class->new(4);
245$z = $x ^ $y;
246ok ($x,5);
247ok ($y,4);
248ok ($z,1);
249
250$x = $class->new(-5); $y = -$x;
251ok ($x, -5);
252
253$x = $class->new(-5); $y = abs($x);
254ok ($x, -5);
255
07d34614 256$x = $class->new(8);
257$y = $class->new(-1);
258$z = $class->new(5033);
259my $u = $x->copy()->bmodpow($y,$z);
260ok ($u,4404);
261ok ($y,-1);
262ok ($z,5033);
263
264$x = $class->new(-5); $y = -$x; ok ($x,-5); ok ($y,5);
265$x = $class->new(-5); $y = $x->copy()->bneg(); ok ($x,-5); ok ($y,5);
266
267$x = $class->new(-5); $y = $class->new(3); $x->bmul($y); ok ($x,-15); ok ($y,3);
268$x = $class->new(-5); $y = $class->new(3); $x->badd($y); ok ($x,-2); ok ($y,3);
269$x = $class->new(-5); $y = $class->new(3); $x->bsub($y); ok ($x,-8); ok ($y,3);
270$x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); ok ($x,-5); ok ($y,3);
271$x = $class->new(-5); $y = $class->new(3); $x->bmod($y); ok ($x,1); ok ($y,3);
272
273$x = $class->new(5); $y = $class->new(3); $x->bmul($y); ok ($x,15); ok ($y,3);
274$x = $class->new(5); $y = $class->new(3); $x->badd($y); ok ($x,8); ok ($y,3);
275$x = $class->new(5); $y = $class->new(3); $x->bsub($y); ok ($x,2); ok ($y,3);
276$x = $class->new(15); $y = $class->new(3); $x->bdiv($y); ok ($x,5); ok ($y,3);
277$x = $class->new(5); $y = $class->new(3); $x->bmod($y); ok ($x,2); ok ($y,3);
278
279$x = $class->new(5); $y = $class->new(-3); $x->bmul($y); ok ($x,-15); ok($y,-3);
280$x = $class->new(5); $y = $class->new(-3); $x->badd($y); ok ($x,2); ok($y,-3);
281$x = $class->new(5); $y = $class->new(-3); $x->bsub($y); ok ($x,8); ok($y,-3);
282$x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); ok ($x,-5); ok($y,-3);
283$x = $class->new(5); $y = $class->new(-3); $x->bmod($y); ok ($x,-1); ok($y,-3);
284
285###############################################################################
6854fd01 286# check whether overloading cmp works
287$try = "\$x = $class->new(0);";
288$try .= "\$y = 10;";
289$try .= "'false' if \$x ne \$y;";
290$ans = eval $try;
291print "# For '$try'\n" if (!ok "$ans" , "false" );
292
293# we cant test for working cmpt with other objects here, we would need a dummy
294# object with stringify overload for this. see Math::String tests as example
295
296###############################################################################
6854fd01 297# check reversed order of arguments
027dc388 298
6854fd01 299$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
300$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
301print "# For '$try'\n" if (!ok "$ans" , "ok" );
302
303$try = "\$x = $class->new(10); \$x = 2 * \$x;";
304$try .= "'ok' if \$x == 20;"; $ans = eval $try;
305print "# For '$try'\n" if (!ok "$ans" , "ok" );
306
307$try = "\$x = $class->new(10); \$x = 2 + \$x;";
308$try .= "'ok' if \$x == 12;"; $ans = eval $try;
309print "# For '$try'\n" if (!ok "$ans" , "ok" );
310
311$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
312$try .= "'ok' if \$x == -8;"; $ans = eval $try;
313print "# For '$try'\n" if (!ok "$ans" , "ok" );
314
315$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
316$try .= "'ok' if \$x == 2;"; $ans = eval $try;
317print "# For '$try'\n" if (!ok "$ans" , "ok" );
318
027dc388 319$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
320$try .= "'ok' if \$x == 2;"; $ans = eval $try;
321print "# For '$try'\n" if (!ok "$ans" , "ok" );
322
323$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
324$try .= "'ok' if \$x == 4;"; $ans = eval $try;
325print "# For '$try'\n" if (!ok "$ans" , "ok" );
326
327$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
328$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
329print "# For '$try'\n" if (!ok "$ans" , "ok" );
330
331$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
332$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
333print "# For '$try'\n" if (!ok "$ans" , "ok" );
334
6854fd01 335###############################################################################
336# check badd(4,5) form
337
338$try = "\$x = $class\->badd(4,5);";
339$try .= "'ok' if \$x == 9;";
340$ans = eval $try;
341print "# For '$try'\n" if (!ok "$ans" , "ok" );
342
343###############################################################################
344# check undefs: NOT DONE YET
345
346###############################################################################
347# bool
348
f9a08e12 349$x = $class->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') }
350$x = $class->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') }
6854fd01 351
352###############################################################################
353# objectify()
354
355@args = Math::BigInt::objectify(2,4,5);
356ok (scalar @args,3); # $class, 4, 5
56b9c951 357ok ($args[0] =~ /^Math::BigInt/);
6854fd01 358ok ($args[1],4);
359ok ($args[2],5);
360
361@args = Math::BigInt::objectify(0,4,5);
362ok (scalar @args,3); # $class, 4, 5
56b9c951 363ok ($args[0] =~ /^Math::BigInt/);
6854fd01 364ok ($args[1],4);
365ok ($args[2],5);
366
367@args = Math::BigInt::objectify(2,4,5);
368ok (scalar @args,3); # $class, 4, 5
56b9c951 369ok ($args[0] =~ /^Math::BigInt/);
6854fd01 370ok ($args[1],4);
371ok ($args[2],5);
372
373@args = Math::BigInt::objectify(2,4,5,6,7);
374ok (scalar @args,5); # $class, 4, 5, 6, 7
56b9c951 375ok ($args[0] =~ /^Math::BigInt/);
6854fd01 376ok ($args[1],4); ok (ref($args[1]),$args[0]);
377ok ($args[2],5); ok (ref($args[2]),$args[0]);
378ok ($args[3],6); ok (ref($args[3]),'');
379ok ($args[4],7); ok (ref($args[4]),'');
380
381@args = Math::BigInt::objectify(2,$class,4,5,6,7);
382ok (scalar @args,5); # $class, 4, 5, 6, 7
383ok ($args[0],$class);
384ok ($args[1],4); ok (ref($args[1]),$args[0]);
385ok ($args[2],5); ok (ref($args[2]),$args[0]);
386ok ($args[3],6); ok (ref($args[3]),'');
387ok ($args[4],7); ok (ref($args[4]),'');
388
389###############################################################################
f9a08e12 390# test whether an opp calls objectify properly or not (or at least does what
391# it should do given non-objects, w/ or w/o objectify())
392
393ok ($class->new(123)->badd(123),246);
394ok ($class->badd(123,321),444);
395ok ($class->badd(123,$class->new(321)),444);
396
397ok ($class->new(123)->bsub(122),1);
398ok ($class->bsub(321,123),198);
399ok ($class->bsub(321,$class->new(123)),198);
400
401ok ($class->new(123)->bmul(123),15129);
402ok ($class->bmul(123,123),15129);
403ok ($class->bmul(123,$class->new(123)),15129);
404
405ok ($class->new(15129)->bdiv(123),123);
406ok ($class->bdiv(15129,123),123);
407ok ($class->bdiv(15129,$class->new(123)),123);
408
409ok ($class->new(15131)->bmod(123),2);
410ok ($class->bmod(15131,123),2);
411ok ($class->bmod(15131,$class->new(123)),2);
412
413ok ($class->new(2)->bpow(16),65536);
414ok ($class->bpow(2,16),65536);
415ok ($class->bpow(2,$class->new(16)),65536);
416
417ok ($class->new(2**15)->brsft(1),2**14);
418ok ($class->brsft(2**15,1),2**14);
419ok ($class->brsft(2**15,$class->new(1)),2**14);
420
421ok ($class->new(2**13)->blsft(1),2**14);
422ok ($class->blsft(2**13,1),2**14);
423ok ($class->blsft(2**13,$class->new(1)),2**14);
424
425###############################################################################
6854fd01 426# test for floating-point input (other tests in bnorm() below)
427
428$z = 1050000000000000; # may be int on systems with 64bit?
429$x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15
430$z = 1e+129; # definitely a float (may fail on UTS)
431# don't compare to $z, since some Perl versions stringify $z into something
432# like '1.e+129' or something equally ugly
433$x = $class->new($z); ok ($x->bsstr(),'1e+129');
434
435###############################################################################
56d9de68 436# test for whitespace inlcuding newlines to be handled correctly
437
438# ok ($Math::BigInt::strict,1); # the default
439
440foreach my $c (
441 qw/1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890/)
442 {
443 my $m = $class->new($c);
444 ok ($class->new("$c"),$m);
445 ok ($class->new(" $c"),$m);
446 ok ($class->new("$c "),$m);
447 ok ($class->new(" $c "),$m);
448 ok ($class->new("\n$c"),$m);
449 ok ($class->new("$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 \n"),$m);
453 ok ($class->new(" \n$c\n "),$m);
454 ok ($class->new(" \n$c\n1"),'NaN');
455 ok ($class->new("1 \n$c\n1"),'NaN');
456 }
457
458###############################################################################
6854fd01 459# prime number tests, also test for **= and length()
460# found on: http://www.utm.edu/research/primes/notes/by_year.html
461
462# ((2^148)-1)/17
463$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
464ok ($x,"20988936657440586486151264256610222593863921");
465ok ($x->length(),length "20988936657440586486151264256610222593863921");
466
467# MM7 = 2^127-1
468$x = $class->new(2); $x **= 127; $x--;
469ok ($x,"170141183460469231731687303715884105727");
470
471$x = $class->new('215960156869840440586892398248');
472($x,$y) = $x->length();
473ok ($x,30); ok ($y,0);
474
475$x = $class->new('1_000_000_000_000');
476($x,$y) = $x->length();
477ok ($x,13); ok ($y,0);
478
479# I am afraid the following is not yet possible due to slowness
480# Also, testing for 2 meg output is a bit hard ;)
481#$x = $class->new(2); $x **= 6972593; $x--;
482
483# 593573509*2^332162+1 has exactly 1,000,000 digits
484# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
485#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
486#ok ($x->length(),1_000_000);
487
488###############################################################################
489# inheritance and overriding of _swap
490
491$x = Math::Foo->new(5);
492$x = $x - 8; # 8 - 5 instead of 5-8
493ok ($x,3);
494ok (ref($x),'Math::Foo');
495
496$x = Math::Foo->new(5);
497$x = 8 - $x; # 5 - 8 instead of 8 - 5
498ok ($x,-3);
499ok (ref($x),'Math::Foo');
500
501###############################################################################
502# Test whether +inf eq inf
503# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
504# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
505# like 1e100000 crash on some platforms. So simple test for the string 'inf'
506$x = $class->new('+inf'); ok ($x,'inf');
507
508###############################################################################
509###############################################################################
56d9de68 510# the followin tests only make sense with Math::BigInt::Calc or BareCalc or
511# FastCalc
6854fd01 512
56d9de68 513exit if $CALC !~ /^Math::BigInt::(|Bare|Fast)Calc$/; # for Pari et al.
6854fd01 514
515###############################################################################
516# check proper length of internal arrays
517
394e6ffb 518my $bl = $CL->_base_len();
6854fd01 519my $BASE = '9' x $bl;
520my $MAX = $BASE;
521$BASE++;
522
523$x = $class->new($MAX); is_valid($x); # f.i. 9999
524$x += 1; ok ($x,$BASE); is_valid($x); # 10000
525$x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again
526
527###############################################################################
528# check numify
529
530$x = $class->new($BASE-1); ok ($x->numify(),$BASE-1);
531$x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1));
61f5c3f5 532
533# +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
534$x = $class->new($BASE); ok ($x->numify()+0,$BASE+0);
6854fd01 535$x = $class->new(-$BASE); ok ($x->numify(),-$BASE);
536$x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
537ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
538
539###############################################################################
540# test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
541
394e6ffb 542$x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
543if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); }
544
545$x = $class->new($BASE+3); $x++;
546if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); }
6854fd01 547
394e6ffb 548# test for +0 instead of int():
549$x = $class->new($MAX); ok ($x->length(), length($MAX));
6854fd01 550
551###############################################################################
56b9c951 552# test bug that $class->digit($string) did not work
553
554ok ($class->digit(123,2),1);
555
556###############################################################################
6854fd01 557# bug in sub where number with at least 6 trailing zeros after any op failed
558
394e6ffb 559$x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
6854fd01 560ok ($z, 100000);
561ok ($x, 23456);
562
563###############################################################################
564# bug in shortcut in mul()
565
61f5c3f5 566# construct a number with a zero-hole of BASE_LEN_SMALL
567{
568 my @bl = $CL->_base_len(); my $bl = $bl[4];
569
570 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
571 $y = '1' x (2*$bl);
572 $x = $class->new($x)->bmul($y);
573 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
574 $y = ''; my $d = '';
575 for (my $i = 1; $i <= $bl; $i++)
576 {
577 $y .= $i; $d = $i.$d;
578 }
579 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
580 ok ($x,$y);
581
6854fd01 582
f9a08e12 583 #############################################################################
584 # see if mul shortcut for small numbers works
394e6ffb 585
f9a08e12 586 $x = '9' x $bl;
587 $x = $class->new($x);
588 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
589 ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
590}
61f5c3f5 591
394e6ffb 592###############################################################################
6854fd01 593# bug with rest "-0" in div, causing further div()s to fail
594
394e6ffb 595$x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
6854fd01 596
61f5c3f5 597ok ($y,'0'); is_valid($y); # $y not '-0'
394e6ffb 598
79c55733 599###############################################################################
f9a08e12 600# bug in $x->bmod($y)
07d34614 601
f9a08e12 602# if $x < 0 and $y > 0
07d34614 603$x = $class->new('-629'); ok ($x->bmod(5033),4404);
604
605###############################################################################
56b9c951 606# bone/binf etc as plain calls (Lite failed them)
607
608ok ($class->bzero(),0);
609ok ($class->bone(),1);
610ok ($class->bone('+'),1);
611ok ($class->bone('-'),-1);
612ok ($class->bnan(),'NaN');
613ok ($class->binf(),'inf');
614ok ($class->binf('+'),'inf');
615ok ($class->binf('-'),'-inf');
616ok ($class->binf('-inf'),'-inf');
617
618###############################################################################
990fb837 619# is_one('-')
620
621ok ($class->new(1)->is_one('-'),0);
622ok ($class->new(-1)->is_one('-'),1);
623ok ($class->new(1)->is_one(),1);
624ok ($class->new(-1)->is_one(),0);
625
626###############################################################################
61f5c3f5 627# all tests done
6854fd01 628
6291;
630
631###############################################################################
61f5c3f5 632###############################################################################
6854fd01 633# Perl 5.005 does not like ok ($x,undef)
634
635sub ok_undef
636 {
637 my $x = shift;
638
639 ok (1,1) and return if !defined $x;
640 ok ($x,'undef');
641 }
642
643###############################################################################
644# sub to check validity of a BigInt internally, to ensure that no op leaves a
645# number object in an invalid state (f.i. "-0")
646
647sub is_valid
648 {
649 my ($x,$f) = @_;
650
651 my $e = 0; # error?
6854fd01 652
56b9c951 653 # allow the check to pass for all Lite, and all MBI and subclasses
654 # ok as reference?
655 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 656
56b9c951 657 if (ref($x) ne 'Math::BigInt::Lite')
658 {
659 # has ok sign?
660 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
661 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
662
663 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
664 $e = $CALC->_check($x->{value}) if $e eq '0';
665 }
6854fd01 666
667 # test done, see if error did crop up
668 ok (1,1), return if ($e eq '0');
669
027dc388 670 ok (1,$e." after op '$f'");
6854fd01 671 }
672
673__DATA__
027dc388 674&.=
6751234:-345:1234-345
676&+=
6771:2:3
678-1:-2:-3
679&-=
6801:2:-1
681-1:-2:1
682&*=
6832:3:6
684-1:5:-5
685&%=
686100:3:1
6878:9:8
07d34614 688-629:5033:4404
027dc388 689&/=
690100:3:33
691-8:2:-4
692&|=
6932:1:3
694&&=
6955:7:5
696&^=
6975:7:2
091c87b1 698&blog
699NaNlog:2:NaN
700122:NaNlog:NaN
701NaNlog1:NaNlog:NaN
702122:inf:NaN
703inf:122:NaN
704122:-inf:NaN
705-inf:122:NaN
706-inf:-inf:NaN
707inf:inf:NaN
7080:4:NaN
709-21:4:NaN
71021:-21:NaN
711# normal results
7121024:2:10
71381:3:4
714# 3.01.. truncate
71582:3:4
716# 3.9... truncate
71780:3:3
71815625:5:6
71915626:5:6
72015624:5:5
8df1e0a2 7211000:10:3
72210000:10:4
723100000:10:5
7241000000:10:6
72510000000:10:7
726100000000:10:8
7278916100448256:12:12
7288916100448257:12:12
7298916100448255:12:11
7302251799813685248:8:17
73172057594037927936:2:56
732144115188075855872:2:57
733288230376151711744:2:58
734576460752303423488:2:59
7354096:2:12
7361329227995784915872903807060280344576:2:120
091c87b1 737# $x == $base => result 1
7383:3:1
739# $x < $base => result 0 ($base ** 0 <= $x)
7403:4:0
741# $x == 1 => result 0
7421:5:0
6854fd01 743&is_negative
7440:0
745-1:1
7461:0
747+inf:0
748-inf:1
749NaNneg:0
750&is_positive
7510:1
752-1:0
7531:1
754+inf:1
755-inf:0
756NaNneg:0
b3abae2a 757&is_int
758-inf:0
759+inf:0
760NaNis_int:0
7611:1
7620:1
763123e12:1
6854fd01 764&is_odd
765abc:0
7660:0
7671:1
7683:1
769-1:1
770-3:1
77110000001:1
77210000002:0
7732:0
b3abae2a 774120:0
775121:1
6854fd01 776&is_even
777abc:0
7780:1
7791:0
7803:0
781-1:0
782-3:0
78310000001:0
78410000002:1
7852:1
b3abae2a 786120:1
787121:0
6854fd01 788&bacmp
789+0:-0:0
790+0:+1:-1
791-1:+1:0
792+1:-1:0
793-1:+2:-1
794+2:-1:1
795-123456789:+987654321:-1
796+123456789:-987654321:-1
797+987654321:+123456789:1
798-987654321:+123456789:1
799-123:+4567889:-1
800# NaNs
801acmpNaN:123:
802123:acmpNaN:
803acmpNaN:acmpNaN:
804# infinity
805+inf:+inf:0
806-inf:-inf:0
807+inf:-inf:0
808-inf:+inf:0
809+inf:123:1
810-inf:123:1
811+inf:-123:1
812-inf:-123:1
813# return undef
814+inf:NaN:
815NaN:inf:
816-inf:NaN:
817NaN:-inf:
818&bnorm
aef458a0 8190e999:0
8200e-999:0
821-0e999:0
822-0e-999:0
6854fd01 823123:123
824# binary input
8250babc:NaN
8260b123:NaN
8270b0:0
828-0b0:0
829-0b1:-1
8300b0001:1
8310b001:1
8320b011:3
8330b101:5
61f5c3f5 8340b1001:9
8350b10001:17
8360b100001:33
8370b1000001:65
8380b10000001:129
8390b100000001:257
8400b1000000001:513
8410b10000000001:1025
8420b100000000001:2049
8430b1000000000001:4097
8440b10000000000001:8193
8450b100000000000001:16385
8460b1000000000000001:32769
8470b10000000000000001:65537
8480b100000000000000001:131073
8490b1000000000000000001:262145
8500b10000000000000000001:524289
8510b100000000000000000001:1048577
8520b1000000000000000000001:2097153
8530b10000000000000000000001:4194305
8540b100000000000000000000001:8388609
8550b1000000000000000000000001:16777217
8560b10000000000000000000000001:33554433
8570b100000000000000000000000001:67108865
8580b1000000000000000000000000001:134217729
8590b10000000000000000000000000001:268435457
8600b100000000000000000000000000001:536870913
8610b1000000000000000000000000000001:1073741825
8620b10000000000000000000000000000001:2147483649
8630b100000000000000000000000000000001:4294967297
8640b1000000000000000000000000000000001:8589934593
8650b10000000000000000000000000000000001:17179869185
6854fd01 8660b_101:NaN
8670b1_0_1:5
394e6ffb 8680b0_0_0_1:1
6854fd01 869# hex input
870-0x0:0
8710xabcdefgh:NaN
8720x1234:4660
8730xabcdef:11259375
874-0xABCDEF:-11259375
875-0x1234:-4660
8760x12345678:305419896
8770x1_2_3_4_56_78:305419896
394e6ffb 8780xa_b_c_d_e_f:11259375
6854fd01 8790x_123:NaN
61f5c3f5 8800x9:9
8810x11:17
8820x21:33
8830x41:65
8840x81:129
8850x101:257
8860x201:513
8870x401:1025
8880x801:2049
8890x1001:4097
8900x2001:8193
8910x4001:16385
8920x8001:32769
8930x10001:65537
8940x20001:131073
8950x40001:262145
8960x80001:524289
8970x100001:1048577
8980x200001:2097153
8990x400001:4194305
9000x800001:8388609
9010x1000001:16777217
9020x2000001:33554433
9030x4000001:67108865
9040x8000001:134217729
9050x10000001:268435457
9060x20000001:536870913
9070x40000001:1073741825
9080x80000001:2147483649
9090x100000001:4294967297
9100x200000001:8589934593
9110x400000001:17179869185
9120x800000001:34359738369
6854fd01 913# inf input
914inf:inf
915+inf:inf
916-inf:-inf
9170inf:NaN
027dc388 918# abnormal input
6854fd01 919:NaN
920abc:NaN
921 1 a:NaN
9221bcd2:NaN
92311111b:NaN
924+1z:NaN
925-1z:NaN
027dc388 926# only one underscore between two digits
927_123:NaN
928_123_:NaN
929123_:NaN
9301__23:NaN
9311E1__2:NaN
9321_E12:NaN
9331E_12:NaN
9341_E_12:NaN
935+_1E12:NaN
936+0_1E2:100
937+0_0_1E2:100
938-0_0_1E2:-100
939-0_0_1E+0_0_2:-100
940E1:NaN
941E23:NaN
9421.23E1:NaN
9431.23E-1:NaN
944# bug with two E's in number beeing valid
9451e2e3:NaN
9461e2r:NaN
9471e2.0:NaN
07d34614 948# bug with two '.' in number beeing valid
9491.2.2:NaN
9501.2.3e1:NaN
951-1.2.3:NaN
952-1.2.3e-4:NaN
9531.2e3.4:NaN
9541.2e-3.4:NaN
9551.2.3.4:NaN
9561.2.t:NaN
9571..2:NaN
9581..2e1:NaN
9591..2e1..1:NaN
96012e1..1:NaN
961..2:NaN
962.-2:NaN
61f5c3f5 963# leading zeros
964012:12
9650123:123
96601234:1234
967012345:12345
9680123456:123456
96901234567:1234567
970012345678:12345678
9710123456789:123456789
97201234567891:1234567891
973012345678912:12345678912
9740123456789123:123456789123
97501234567891234:1234567891234
027dc388 976# normal input
6854fd01 9770:0
978+0:0
979+00:0
980+000:0
981000000000000000000:0
982-0:0
983-0000:0
984+1:1
985+01:1
986+001:1
987+00000100000:100000
988123456789:123456789
989-1:-1
990-01:-1
991-001:-1
992-123456789:-123456789
993-00000100000:-100000
9941_2_3:123
6854fd01 99510000000000E-1_0:1
9961E2:100
9971E1:10
9981E0:1
6854fd01 9991.23E2:123
6854fd01 1000100E-1:10
1001# floating point input
027dc388 1002# .2e2:20
10031.E3:1000
6854fd01 10041.01E2:101
10051010E-1:101
1006-1010E0:-1010
1007-1010E1:-10100
027dc388 10081234.00:1234
1009# non-integer numbers
6854fd01 1010-1010E-2:NaN
1011-1.01E+1:NaN
1012-1.01E-1:NaN
6854fd01 1013&bnan
10141:NaN
10152:NaN
1016abc:NaN
1017&bone
61f5c3f5 10182:+:1
6854fd01 10192:-:-1
1020boneNaN:-:-1
61f5c3f5 1021boneNaN:+:1
10222:abc:1
10233::1
6854fd01 1024&binf
10251:+:inf
10262:-:-inf
10273:abc:inf
027dc388 1028&is_nan
1029123:0
1030abc:1
1031NaN:1
1032-123:0
6854fd01 1033&is_inf
1034+inf::1
1035-inf::1
1036abc::0
10371::0
1038NaN::0
1039-1::0
1040+inf:-:0
1041+inf:+:1
1042-inf:-:1
1043-inf:+:0
79c55733 1044-inf:-inf:1
1045-inf:+inf:0
1046+inf:-inf:0
1047+inf:+inf:1
6854fd01 1048# it must be exactly /^[+-]inf$/
1049+infinity::0
1050-infinity::0
1051&blsft
1052abc:abc:NaN
61f5c3f5 1053+2:+2:8
1054+1:+32:4294967296
1055+1:+48:281474976710656
6854fd01 1056+8:-2:NaN
1057# excercise base 10
1058+12345:4:10:123450000
1059-1234:0:10:-1234
61f5c3f5 1060+1234:0:10:1234
6854fd01 1061+2:2:10:200
1062+12:2:10:1200
1063+1234:-3:10:NaN
10641234567890123:12:10:1234567890123000000000000
b3abae2a 1065-3:1:2:-6
1066-5:1:2:-10
1067-2:1:2:-4
1068-102533203:1:2:-205066406
6854fd01 1069&brsft
1070abc:abc:NaN
61f5c3f5 1071+8:+2:2
1072+4294967296:+32:1
1073+281474976710656:+48:1
6854fd01 1074+2:-2:NaN
1075# excercise base 10
1076-1234:0:10:-1234
61f5c3f5 1077+1234:0:10:1234
6854fd01 1078+200:2:10:2
1079+1234:3:10:1
1080+1234:2:10:12
1081+1234:-3:10:NaN
1082310000:4:10:31
108312300000:5:10:123
10841230000000000:10:10:123
108509876123456789067890:12:10:9876123
10861234561234567890123:13:10:123456
b3abae2a 1087820265627:1:2:410132813
1088# test shifting negative numbers in base 2
1089-15:1:2:-8
1090-14:1:2:-7
1091-13:1:2:-7
1092-12:1:2:-6
1093-11:1:2:-6
1094-10:1:2:-5
1095-9:1:2:-5
1096-8:1:2:-4
1097-7:1:2:-4
1098-6:1:2:-3
1099-5:1:2:-3
1100-4:1:2:-2
1101-3:1:2:-2
1102-2:1:2:-1
1103-1:1:2:-1
1104-1640531254:2:2:-410132814
1105-1640531254:1:2:-820265627
1106-820265627:1:2:-410132814
1107-205066405:1:2:-102533203
6854fd01 1108&bsstr
56d9de68 1109+inf:inf
1110-inf:-inf
6854fd01 11111e+34:1e+34
1112123.456E3:123456e+0
1113100:1e+2
56d9de68 1114bsstrabc:NaN
1115-5:-5e+0
1116-100:-1e+2
1117&numify
1118numifyabc:NaN
1119+inf:inf
1120-inf:-inf
11215:5
1122-5:-5
1123100:100
1124-100:-100
6854fd01 1125&bneg
1126bnegNaN:NaN
1127+inf:-inf
1128-inf:inf
1129abd:NaN
61f5c3f5 11300:0
11311:-1
1132-1:1
6854fd01 1133+123456789:-123456789
61f5c3f5 1134-123456789:123456789
6854fd01 1135&babs
1136babsNaN:NaN
1137+inf:inf
1138-inf:inf
61f5c3f5 11390:0
11401:1
1141-1:1
1142+123456789:123456789
1143-123456789:123456789
6854fd01 1144&bcmp
1145bcmpNaN:bcmpNaN:
61f5c3f5 1146bcmpNaN:0:
11470:bcmpNaN:
11480:0:0
1149-1:0:-1
11500:-1:1
11511:0:1
11520:1:-1
1153-1:1:-1
11541:-1:1
6854fd01 1155-1:-1:0
61f5c3f5 11561:1:0
1157123:123:0
1158123:12:1
115912:123:-1
6854fd01 1160-123:-123:0
1161-123:-12:-1
1162-12:-123:1
61f5c3f5 1163123:124:-1
1164124:123:1
6854fd01 1165-123:-124:1
1166-124:-123:-1
61f5c3f5 1167100:5:1
1168-123456789:987654321:-1
6854fd01 1169+123456789:-987654321:1
61f5c3f5 1170-987654321:123456789:-1
6854fd01 1171-inf:5432112345:-1
1172+inf:5432112345:1
1173-inf:-5432112345:-1
1174+inf:-5432112345:1
1175+inf:+inf:0
1176-inf:-inf:0
1177+inf:-inf:1
1178-inf:+inf:-1
11795:inf:-1
11805:inf:-1
1181-5:-inf:1
1182-5:-inf:1
1183# return undef
1184+inf:NaN:
1185NaN:inf:
1186-inf:NaN:
1187NaN:-inf:
1188&binc
1189abc:NaN
1190+inf:inf
1191-inf:-inf
61f5c3f5 1192+0:1
1193+1:2
1194-1:0
6854fd01 1195&bdec
1196abc:NaN
1197+inf:inf
1198-inf:-inf
1199+0:-1
61f5c3f5 1200+1:0
6854fd01 1201-1:-2
1202&badd
1203abc:abc:NaN
61f5c3f5 1204abc:0:NaN
6854fd01 1205+0:abc:NaN
b3abae2a 1206+inf:-inf:NaN
1207-inf:+inf:NaN
6854fd01 1208+inf:+inf:inf
1209-inf:-inf:-inf
1210baddNaN:+inf:NaN
1211baddNaN:+inf:NaN
1212+inf:baddNaN:NaN
1213-inf:baddNaN:NaN
61f5c3f5 12140:0:0
12151:0:1
12160:1:1
12171:1:2
1218-1:0:-1
12190:-1:-1
6854fd01 1220-1:-1:-2
61f5c3f5 1221-1:+1:0
1222+1:-1:0
1223+9:+1:10
1224+99:+1:100
1225+999:+1:1000
1226+9999:+1:10000
1227+99999:+1:100000
1228+999999:+1:1000000
1229+9999999:+1:10000000
1230+99999999:+1:100000000
1231+999999999:+1:1000000000
1232+9999999999:+1:10000000000
1233+99999999999:+1:100000000000
1234+10:-1:9
1235+100:-1:99
1236+1000:-1:999
1237+10000:-1:9999
1238+100000:-1:99999
1239+1000000:-1:999999
1240+10000000:-1:9999999
1241+100000000:-1:99999999
1242+1000000000:-1:999999999
1243+10000000000:-1:9999999999
1244+123456789:987654321:1111111110
1245-123456789:987654321:864197532
6854fd01 1246-123456789:-987654321:-1111111110
1247+123456789:-987654321:-864197532
56b9c951 1248-1:10001:10000
1249-1:100001:100000
1250-1:1000001:1000000
1251-1:10000001:10000000
1252-1:100000001:100000000
1253-1:1000000001:1000000000
1254-1:10000000001:10000000000
1255-1:100000000001:100000000000
1256-1:1000000000001:1000000000000
1257-1:10000000000001:10000000000000
1258-1:-10001:-10002
1259-1:-100001:-100002
1260-1:-1000001:-1000002
1261-1:-10000001:-10000002
1262-1:-100000001:-100000002
1263-1:-1000000001:-1000000002
1264-1:-10000000001:-10000000002
1265-1:-100000000001:-100000000002
1266-1:-1000000000001:-1000000000002
1267-1:-10000000000001:-10000000000002
6854fd01 1268&bsub
1269abc:abc:NaN
1270abc:+0:NaN
1271+0:abc:NaN
1272+inf:-inf:inf
1273-inf:+inf:-inf
b3abae2a 1274+inf:+inf:NaN
1275-inf:-inf:NaN
61f5c3f5 1276+0:+0:0
1277+1:+0:1
6854fd01 1278+0:+1:-1
61f5c3f5 1279+1:+1:0
6854fd01 1280-1:+0:-1
61f5c3f5 1281+0:-1:1
1282-1:-1:0
6854fd01 1283-1:+1:-2
61f5c3f5 1284+1:-1:2
1285+9:+1:8
1286+99:+1:98
1287+999:+1:998
1288+9999:+1:9998
1289+99999:+1:99998
1290+999999:+1:999998
1291+9999999:+1:9999998
1292+99999999:+1:99999998
1293+999999999:+1:999999998
1294+9999999999:+1:9999999998
1295+99999999999:+1:99999999998
1296+10:-1:11
1297+100:-1:101
1298+1000:-1:1001
1299+10000:-1:10001
1300+100000:-1:100001
1301+1000000:-1:1000001
1302+10000000:-1:10000001
1303+100000000:-1:100000001
1304+1000000000:-1:1000000001
1305+10000000000:-1:10000000001
6854fd01 1306+123456789:+987654321:-864197532
1307-123456789:+987654321:-1111111110
61f5c3f5 1308-123456789:-987654321:864197532
1309+123456789:-987654321:1111111110
56b9c951 131010001:1:10000
1311100001:1:100000
13121000001:1:1000000
131310000001:1:10000000
1314100000001:1:100000000
13151000000001:1:1000000000
131610000000001:1:10000000000
1317100000000001:1:100000000000
13181000000000001:1:1000000000000
131910000000000001:1:10000000000000
132010001:-1:10002
1321100001:-1:100002
13221000001:-1:1000002
132310000001:-1:10000002
1324100000001:-1:100000002
13251000000001:-1:1000000002
132610000000001:-1:10000000002
1327100000000001:-1:100000000002
13281000000000001:-1:1000000000002
132910000000000001:-1:10000000000002
6854fd01 1330&bmul
1331abc:abc:NaN
1332abc:+0:NaN
1333+0:abc:NaN
1334NaNmul:+inf:NaN
1335NaNmul:-inf:NaN
1336-inf:NaNmul:NaN
1337+inf:NaNmul:NaN
1338+inf:+inf:inf
1339+inf:-inf:-inf
1340-inf:+inf:-inf
1341-inf:-inf:inf
61f5c3f5 1342+0:+0:0
1343+0:+1:0
1344+1:+0:0
1345+0:-1:0
1346-1:+0:0
1347123456789123456789:0:0
13480:123456789123456789:0
1349-1:-1:1
6854fd01 1350-1:+1:-1
1351+1:-1:-1
61f5c3f5 1352+1:+1:1
1353+2:+3:6
6854fd01 1354-2:+3:-6
1355+2:-3:-6
61f5c3f5 1356-2:-3:6
1357111:111:12321
135810101:10101:102030201
13591001001:1001001:1002003002001
1360100010001:100010001:10002000300020001
136110000100001:10000100001:100002000030000200001
136211111111111:9:99999999999
136322222222222:9:199999999998
136433333333333:9:299999999997
136544444444444:9:399999999996
136655555555555:9:499999999995
136766666666666:9:599999999994
136877777777777:9:699999999993
136988888888888:9:799999999992
137099999999999:9:899999999991
1371+25:+25:625
1372+12345:+12345:152399025
1373+99999:+11111:1111088889
6854fd01 13749999:10000:99990000
137599999:100000:9999900000
1376999999:1000000:999999000000
13779999999:10000000:99999990000000
137899999999:100000000:9999999900000000
1379999999999:1000000000:999999999000000000
13809999999999:10000000000:99999999990000000000
138199999999999:100000000000:9999999999900000000000
1382999999999999:1000000000000:999999999999000000000000
13839999999999999:10000000000000:99999999999990000000000000
138499999999999999:100000000000000:9999999999999900000000000000
1385999999999999999:1000000000000000:999999999999999000000000000000
13869999999999999999:10000000000000000:99999999999999990000000000000000
138799999999999999999:100000000000000000:9999999999999999900000000000000000
1388999999999999999999:1000000000000000000:999999999999999999000000000000000000
13899999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1390&bdiv-list
1391100:20:5,0
13924095:4095:1,0
1393-4095:-4095:1,0
13944095:-4095:-1,0
1395-4095:4095:-1,0
1396123:2:61,1
b3abae2a 13979:5:1,4
13989:4:2,1
6854fd01 1399# inf handling and general remainder
14005:8:0,5
14010:8:0,0
140211:2:5,1
140311:-2:-5,-1
1404-11:2:-5,1
1405# see table in documentation in MBI
14060:inf:0,0
14070:-inf:0,0
14085:inf:0,5
14095:-inf:0,5
1410-5:inf:0,-5
1411-5:-inf:0,-5
1412inf:5:inf,0
1413-inf:5:-inf,0
1414inf:-5:-inf,0
1415-inf:-5:inf,0
14165:5:1,0
1417-5:-5:1,0
b3abae2a 1418inf:inf:NaN,NaN
1419-inf:-inf:NaN,NaN
1420-inf:inf:NaN,NaN
1421inf:-inf:NaN,NaN
6854fd01 14228:0:inf,8
1423inf:0:inf,inf
1424# exceptions to reminder rule
1425-8:0:-inf,-8
1426-inf:0:-inf,-inf
14270:0:NaN,NaN
990fb837 1428# test the shortcut in Calc if @$x == @$yorg
14291234567812345678:123456712345678:10,688888898
143012345671234567:1234561234567:10,58888897
1431123456123456:12345123456:10,4888896
14321234512345:123412345:10,388895
14331234567890999999999:1234567890:1000000000,999999999
14341234567890000000000:1234567890:1000000000,0
14351234567890999999999:9876543210:124999998,9503086419
14361234567890000000000:9876543210:124999998,8503086420
143796969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
6854fd01 1438&bdiv
1439abc:abc:NaN
61f5c3f5 1440abc:1:NaN
14411:abc:NaN
14420:0:NaN
6854fd01 1443# inf handling (see table in doc)
14440:inf:0
14450:-inf:0
14465:inf:0
14475:-inf:0
1448-5:inf:0
1449-5:-inf:0
1450inf:5:inf
1451-inf:5:-inf
1452inf:-5:-inf
1453-inf:-5:inf
14545:5:1
1455-5:-5:1
b3abae2a 1456inf:inf:NaN
1457-inf:-inf:NaN
1458-inf:inf:NaN
1459inf:-inf:NaN
6854fd01 14608:0:inf
1461inf:0:inf
1462-8:0:-inf
1463-inf:0:-inf
14640:0:NaN
146511:2:5
1466-11:-2:5
1467-11:2:-5
146811:-2:-5
61f5c3f5 14690:1:0
14700:-1:0
14711:1:1
1472-1:-1:1
14731:-1:-1
1474-1:1:-1
14751:2:0
14762:1:2
14771:26:0
14781000000000:9:111111111
14792000000000:9:222222222
14803000000000:9:333333333
14814000000000:9:444444444
14825000000000:9:555555555
14836000000000:9:666666666
14847000000000:9:777777777
14858000000000:9:888888888
14869000000000:9:1000000000
148735500000:113:314159
148871000000:226:314159
1489106500000:339:314159
14901000000000:3:333333333
1491+10:+5:2
1492+100:+4:25
1493+1000:+8:125
1494+10000:+16:625
1495999999999999:9:111111111111
1496999999999999:99:10101010101
1497999999999999:999:1001001001
1498999999999999:9999:100010001
1499999999999999999:99999:10000100001
1500+1111088889:99999:11111
6854fd01 1501-5:-3:1
1502-5:3:-1
15034:3:1
15044:-3:-1
15051:3:0
15061:-3:0
1507-2:-3:0
1508-2:3:0
15098:3:2
1510-8:3:-2
151114:-3:-4
1512-14:3:-4
1513-14:-3:4
151414:3:4
1515# bug in Calc with '99999' vs $BASE-1
151610000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
990fb837 1517# test the shortcut in Calc if @$x == @$yorg
15181234567812345678:123456712345678:10
151912345671234567:1234561234567:10
1520123456123456:12345123456:10
15211234512345:123412345:10
15221234567890999999999:1234567890:1000000000
15231234567890000000000:1234567890:1000000000
15241234567890999999999:9876543210:124999998
15251234567890000000000:9876543210:124999998
152696969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
aef458a0 1527# bug up to v0.35 in Calc (--$q one too many)
152884696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
152984696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
153084696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
153184696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
07d34614 1532&bmodinv
1533# format: number:modulus:result
1534# bmodinv Data errors
1535abc:abc:NaN
1536abc:5:NaN
15375:abc:NaN
1538# bmodinv Expected Results from normal use
15391:5:1
15403:5:2
1541-2:5:2
15428:5033:4404
56d9de68 15431234567891:13:6
1544-1234567891:13:7
07d34614 1545324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
d614cd8b 1546## bmodinv Error cases / useless use of function
07d34614 15473:-5:NaN
1548inf:5:NaN
1ddff52a 15495:inf:NaN
1550-inf:5:NaN
15515:-inf:NaN
07d34614 1552&bmodpow
1553# format: number:exponent:modulus:result
1554# bmodpow Data errors
1555abc:abc:abc:NaN
15565:abc:abc:NaN
1557abc:5:abc:NaN
1558abc:abc:5:NaN
15595:5:abc:NaN
15605:abc:5:NaN
1561abc:5:5:NaN
1562# bmodpow Expected results
15630:0:2:1
15641:0:2:1
15650:0:1:0
15668:7:5032:3840
15678:-1:5033:4404
156898436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1569# bmodpow Error cases
15708:8:-5:NaN
15718:-1:16:NaN
1572inf:5:13:NaN
15735:inf:13:NaN
6854fd01 1574&bmod
1575# inf handling, see table in doc
15760:inf:0
15770:-inf:0
15785:inf:5
15795:-inf:5
1580-5:inf:-5
1581-5:-inf:-5
1582inf:5:0
1583-inf:5:0
1584inf:-5:0
1585-inf:-5:0
15865:5:0
1587-5:-5:0
b3abae2a 1588inf:inf:NaN
1589-inf:-inf:NaN
1590-inf:inf:NaN
1591inf:-inf:NaN
6854fd01 15928:0:8
1593inf:0:inf
1594# exceptions to reminder rule
1595-inf:0:-inf
1596-8:0:-8
15970:0:NaN
1598abc:abc:NaN
61f5c3f5 1599abc:1:abc:NaN
16001:abc:NaN
16010:0:NaN
16020:1:0
16031:0:1
16040:-1:0
1605-1:0:-1
16061:1:0
1607-1:-1:0
16081:-1:0
1609-1:1:0
16101:2:1
16112:1:0
16121000000000:9:1
16132000000000:9:2
16143000000000:9:3
16154000000000:9:4
16165000000000:9:5
16176000000000:9:6
16187000000000:9:7
16198000000000:9:8
16209000000000:9:0
162135500000:113:33
162271000000:226:66
1623106500000:339:99
16241000000000:3:1
162510:5:0
1626100:4:0
16271000:8:0
162810000:16:0
1629999999999999:9:0
1630999999999999:99:0
1631999999999999:999:0
1632999999999999:9999:0
1633999999999999999:99999:0
1634-9:+5:1
6854fd01 1635+9:-5:-1
1636-9:-5:-4
1637-5:3:1
1638-2:3:1
16394:3:1
16401:3:1
1641-5:-3:-2
1642-2:-3:-2
16434:-3:-2
16441:-3:-2
16454095:4095:0
027dc388 1646100041000510123:3:0
1647152403346:12345:4321
b3abae2a 16489:5:4
28df3e88 1649# test shortcuts in Calc
1650# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
16511234:9:1
1652123456:9:3
165312345678:9:0
16541234567891:9:1
1655123456789123:9:6
165612345678912345:9:6
16571234567891234567:9:1
1658123456789123456789:9:0
16591234:10:4
1660123456:10:6
166112345678:10:8
16621234567891:10:1
1663123456789123:10:3
166412345678912345:10:5
16651234567891234567:10:7
1666123456789123456789:10:9
16671234:113:104
1668123456:113:60
166912345678:113:89
16701234567891:113:64
1671123456789123:113:95
167212345678912345:113:53
16731234567891234567:113:56
1674123456789123456789:113:39
07d34614 1675# bug in bmod() not modifying the variable in place
1676-629:5033:4404
aef458a0 1677# bug in bmod() in Calc in the _div_use_div() shortcut code path,
1678# when X == X and X was big
1679111111111111111111111111111111:111111111111111111111111111111:0
168012345678901234567890:12345678901234567890:0
6854fd01 1681&bgcd
1682abc:abc:NaN
1683abc:+0:NaN
1684+0:abc:NaN
61f5c3f5 1685+0:+0:0
1686+0:+1:1
1687+1:+0:1
1688+1:+1:1
1689+2:+3:1
1690+3:+2:1
1691-3:+2:1
1692100:625:25
16934096:81:1
16941034:804:2
169527:90:56:1
169627:90:54:9
6854fd01 1697&blcm
1698abc:abc:NaN
1699abc:+0:NaN
1700+0:abc:NaN
1701+0:+0:NaN
61f5c3f5 1702+1:+0:0
1703+0:+1:0
1704+27:+90:270
1705+1034:+804:415668
6854fd01 1706&band
1707abc:abc:NaN
1708abc:0:NaN
17090:abc:NaN
17101:2:0
17113:2:2
61f5c3f5 1712+8:+2:0
1713+281474976710656:0:0
1714+281474976710656:1:0
1715+281474976710656:+281474976710656:281474976710656
6854fd01 1716-2:-3:-4
1717-1:-1:-1
1718-6:-6:-6
1719-7:-4:-8
1720-7:4:0
1721-4:7:4
394e6ffb 1722# equal arguments are treated special, so also do some test with unequal ones
17230xFFFF:0xFFFF:0x0xFFFF
17240xFFFFFF:0xFFFFFF:0x0xFFFFFF
17250xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
17260xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17270xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17280xF0F0:0xF0F0:0x0xF0F0
17290x0F0F:0x0F0F:0x0x0F0F
17300xF0F0F0:0xF0F0F0:0x0xF0F0F0
17310x0F0F0F:0x0F0F0F:0x0x0F0F0F
17320xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
17330x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
17340xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
17350x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
17360xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
17370x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
17380x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01 1739&bior
1740abc:abc:NaN
1741abc:0:NaN
17420:abc:NaN
17431:2:3
61f5c3f5 1744+8:+2:10
1745+281474976710656:0:281474976710656
1746+281474976710656:1:281474976710657
1747+281474976710656:281474976710656:281474976710656
6854fd01 1748-2:-3:-1
1749-1:-1:-1
1750-6:-6:-6
1751-7:4:-3
1752-4:7:-1
394e6ffb 1753# equal arguments are treated special, so also do some test with unequal ones
17540xFFFF:0xFFFF:0x0xFFFF
17550xFFFFFF:0xFFFFFF:0x0xFFFFFF
17560xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
17570xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17580xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17590:0xFFFF:0x0xFFFF
17600:0xFFFFFF:0x0xFFFFFF
17610:0xFFFFFFFF:0x0xFFFFFFFF
17620:0xFFFFFFFFFF:0x0xFFFFFFFFFF
17630:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
17640xFFFF:0:0x0xFFFF
17650xFFFFFF:0:0x0xFFFFFF
17660xFFFFFFFF:0:0x0xFFFFFFFF
17670xFFFFFFFFFF:0:0x0xFFFFFFFFFF
17680xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
17690xF0F0:0xF0F0:0x0xF0F0
17700x0F0F:0x0F0F:0x0x0F0F
17710xF0F0:0x0F0F:0x0xFFFF
17720xF0F0F0:0xF0F0F0:0x0xF0F0F0
17730x0F0F0F:0x0F0F0F:0x0x0F0F0F
17740x0F0F0F:0xF0F0F0:0x0xFFFFFF
17750xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
17760x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
17770x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
17780xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
17790x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
17800x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
17810xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
17820x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
17830x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
17840x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1785&bxor
1786abc:abc:NaN
1787abc:0:NaN
17880:abc:NaN
17891:2:3
61f5c3f5 1790+8:+2:10
1791+281474976710656:0:281474976710656
1792+281474976710656:1:281474976710657
1793+281474976710656:281474976710656:0
6854fd01 1794-2:-3:3
1795-1:-1:0
1796-6:-6:0
1797-7:4:-3
1798-4:7:-5
17994:-7:-3
1800-4:-7:5
394e6ffb 1801# equal arguments are treated special, so also do some test with unequal ones
18020xFFFF:0xFFFF:0
18030xFFFFFF:0xFFFFFF:0
18040xFFFFFFFF:0xFFFFFFFF:0
18050xFFFFFFFFFF:0xFFFFFFFFFF:0
18060xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
18070:0xFFFF:0x0xFFFF
18080:0xFFFFFF:0x0xFFFFFF
18090:0xFFFFFFFF:0x0xFFFFFFFF
18100:0xFFFFFFFFFF:0x0xFFFFFFFFFF
18110:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
18120xFFFF:0:0x0xFFFF
18130xFFFFFF:0:0x0xFFFFFF
18140xFFFFFFFF:0:0x0xFFFFFFFF
18150xFFFFFFFFFF:0:0x0xFFFFFFFFFF
18160xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
18170xF0F0:0xF0F0:0
18180x0F0F:0x0F0F:0
18190xF0F0:0x0F0F:0x0xFFFF
18200xF0F0F0:0xF0F0F0:0
18210x0F0F0F:0x0F0F0F:0
18220x0F0F0F:0xF0F0F0:0x0xFFFFFF
18230xF0F0F0F0:0xF0F0F0F0:0
18240x0F0F0F0F:0x0F0F0F0F:0
18250x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
18260xF0F0F0F0F0:0xF0F0F0F0F0:0
18270x0F0F0F0F0F:0x0F0F0F0F0F:0
18280x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
18290xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
18300x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
18310x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01 1832&bnot
1833abc:NaN
1834+0:-1
1835+8:-9
1836+281474976710656:-281474976710657
1837-1:0
1838-2:1
1839-12:11
1840&digit
18410:0:0
184212:0:2
184312:1:1
1844123:0:3
1845123:1:2
1846123:2:1
1847123:-1:1
1848123:-2:2
1849123:-3:3
1850123456:0:6
1851123456:1:5
1852123456:2:4
1853123456:3:3
1854123456:4:2
1855123456:5:1
1856123456:-1:1
1857123456:-2:2
1858123456:-3:3
1859100000:-3:0
1860100000:0:0
1861100000:1:0
1862&mantissa
1863abc:NaN
18641e4:1
18652e0:2
1866123:123
1867-1:-1
1868-2:-2
1869+inf:inf
1870-inf:-inf
1871&exponent
1872abc:NaN
18731e4:4
18742e0:0
1875123:0
1876-1:0
1877-2:0
18780:1
1879+inf:inf
1880-inf:inf
1881&parts
1882abc:NaN,NaN
18831e4:1,4
18842e0:2,0
1885123:123,0
1886-1:-1,0
1887-2:-2,0
18880:0,1
1889+inf:inf,inf
1890-inf:-inf,inf
b3abae2a 1891&bfac
1892-1:NaN
1893NaNfac:NaN
b282a552 1894+inf:inf
b3abae2a 1895-inf:NaN
18960:1
18971:1
18982:2
18993:6
19004:24
19015:120
19026:720
990fb837 19037:5040
19048:40320
19059:362880
b3abae2a 190610:3628800
190711:39916800
190812:479001600
6854fd01 1909&bpow
1910abc:12:NaN
191112:abc:NaN
19120:0:1
19130:1:0
19140:2:0
19150:-1:NaN
19160:-2:NaN
19171:0:1
19181:1:1
19191:2:1
19201:3:1
19211:-1:1
19221:-2:1
19231:-3:1
19242:0:1
19252:1:2
19262:2:4
19272:3:8
19283:3:27
19292:-1:NaN
1930-2:-1:NaN
19312:-2:NaN
1932-2:-2:NaN
1933+inf:1234500012:inf
1934-inf:1234500012:-inf
1935+inf:-12345000123:inf
1936-inf:-12345000123:-inf
1937# 1 ** -x => 1 / (1 ** x)
1938-1:0:1
1939-2:0:1
1940-1:1:-1
1941-1:2:1
1942-1:3:-1
1943-1:4:1
1944-1:5:-1
1945-1:-1:-1
1946-1:-2:1
1947-1:-3:-1
1948-1:-4:1
194910:2:100
195010:3:1000
195110:4:10000
195210:5:100000
195310:6:1000000
195410:7:10000000
195510:8:100000000
195610:9:1000000000
195710:20:100000000000000000000
1958123456:2:15241383936
1959&length
1960100:3
196110:2
19621:1
19630:1
196412345:5
196510000000000000000:17
1966-123:3
1967215960156869840440586892398248:30
990fb837 1968&broot
1969# sqrt()
1970+0:2:0
1971+1:2:1
1972-1:2:NaN
1973# -$x ** (1/2) => -$y, but not in froot()
1974-123:2:NaN
1975+inf:2:inf
1976-inf:2:NaN
19772:2:1
1978-2:2:NaN
19794:2:2
19809:2:3
198116:2:4
1982100:2:10
1983123:2:11
198415241:2:123
1985144:2:12
198612:2:3
19870.49:2:0
19880.0049:2:0
1989# invalid ones
19901:NaN:NaN
1991-1:NaN:NaN
19920:NaN:NaN
1993-inf:NaN:NaN
1994+inf:NaN:NaN
1995NaN:0:NaN
1996NaN:2:NaN
1997NaN:inf:NaN
1998NaN:inf:NaN
199912:-inf:NaN
200012:inf:NaN
2001+0:0:NaN
2002+1:0:NaN
2003-1:0:NaN
2004-2:0:NaN
2005-123.45:0:NaN
2006+inf:0:NaN
200712:1:12
2008-12:1:NaN
20098:-1:NaN
2010-8:-1:NaN
2011# cubic root
20128:3:2
2013-8:3:NaN
2014# fourths root
c38b2de2 201516:4:2
201681:4:3
2017# 2 ** 32
201818446744073709551616:4:65536
201918446744073709551616:8:256
202018446744073709551616:16:16
202118446744073709551616:32:4
202218446744073709551616:64:2
202318446744073709551616:128:1
6854fd01 2024&bsqrt
394e6ffb 2025145:12
6854fd01 2026144:12
394e6ffb 2027143:11
6854fd01 202816:4
394e6ffb 2029170:13
2030169:13
2031168:12
6854fd01 20324:2
394e6ffb 20333:1
6854fd01 20342:1
394e6ffb 20359:3
6854fd01 203612:3
2037256:16
2038100000000:10000
20394000000000000:2000000
394e6ffb 2040152399026:12345
2041152399025:12345
2042152399024:12344
6854fd01 20431:1
20440:0
2045-2:NaN
394e6ffb 2046-123:NaN
6854fd01 2047Nan:NaN
990fb837 2048+inf:inf
2049-inf:NaN
6854fd01 2050&bround
2051$round_mode('trunc')
20520:12:0
2053NaNbround:12:NaN
2054+inf:12:inf
2055-inf:12:-inf
20561234:0:1234
20571234:2:1200
2058123456:4:123400
2059123456:5:123450
2060123456:6:123456
61f5c3f5 2061+10123456789:5:10123000000
6854fd01 2062-10123456789:5:-10123000000
61f5c3f5 2063+10123456789:9:10123456700
6854fd01 2064-10123456789:9:-10123456700
61f5c3f5 2065+101234500:6:101234000
6854fd01 2066-101234500:6:-101234000
61f5c3f5 2067#+101234500:-4:101234000
6854fd01 2068#-101234500:-4:-101234000
2069$round_mode('zero')
61f5c3f5 2070+20123456789:5:20123000000
6854fd01 2071-20123456789:5:-20123000000
61f5c3f5 2072+20123456789:9:20123456800
6854fd01 2073-20123456789:9:-20123456800
61f5c3f5 2074+201234500:6:201234000
6854fd01 2075-201234500:6:-201234000
61f5c3f5 2076#+201234500:-4:201234000
6854fd01 2077#-201234500:-4:-201234000
2078+12345000:4:12340000
2079-12345000:4:-12340000
2080$round_mode('+inf')
61f5c3f5 2081+30123456789:5:30123000000
6854fd01 2082-30123456789:5:-30123000000
61f5c3f5 2083+30123456789:9:30123456800
6854fd01 2084-30123456789:9:-30123456800
61f5c3f5 2085+301234500:6:301235000
6854fd01 2086-301234500:6:-301234000
61f5c3f5 2087#+301234500:-4:301235000
6854fd01 2088#-301234500:-4:-301234000
2089+12345000:4:12350000
2090-12345000:4:-12340000
2091$round_mode('-inf')
61f5c3f5 2092+40123456789:5:40123000000
6854fd01 2093-40123456789:5:-40123000000
61f5c3f5 2094+40123456789:9:40123456800
6854fd01 2095-40123456789:9:-40123456800
61f5c3f5 2096+401234500:6:401234000
2097+401234500:6:401234000
6854fd01 2098#-401234500:-4:-401235000
2099#-401234500:-4:-401235000
2100+12345000:4:12340000
2101-12345000:4:-12350000
2102$round_mode('odd')
61f5c3f5 2103+50123456789:5:50123000000
6854fd01 2104-50123456789:5:-50123000000
61f5c3f5 2105+50123456789:9:50123456800
6854fd01 2106-50123456789:9:-50123456800
61f5c3f5 2107+501234500:6:501235000
6854fd01 2108-501234500:6:-501235000
61f5c3f5 2109#+501234500:-4:501235000
6854fd01 2110#-501234500:-4:-501235000
2111+12345000:4:12350000
2112-12345000:4:-12350000
2113$round_mode('even')
61f5c3f5 2114+60123456789:5:60123000000
6854fd01 2115-60123456789:5:-60123000000
61f5c3f5 2116+60123456789:9:60123456800
6854fd01 2117-60123456789:9:-60123456800
61f5c3f5 2118+601234500:6:601234000
6854fd01 2119-601234500:6:-601234000
61f5c3f5 2120#+601234500:-4:601234000
6854fd01 2121#-601234500:-4:-601234000
2122#-601234500:-9:0
2123#-501234500:-9:0
2124#-601234500:-8:0
2125#-501234500:-8:0
2126+1234567:7:1234567
2127+1234567:6:1234570
2128+12345000:4:12340000
2129-12345000:4:-12340000
2130&is_zero
21310:1
2132NaNzero:0
2133+inf:0
2134-inf:0
2135123:0
2136-1:0
21371:0
2138&is_one
21390:0
2140NaNone:0
2141+inf:0
2142-inf:0
21431:1
21442:0
2145-1:0
2146-2:0
2147# floor and ceil tests are pretty pointless in integer space...but play safe
2148&bfloor
21490:0
2150NaNfloor:NaN
2151+inf:inf
2152-inf:-inf
2153-1:-1
2154-2:-2
21552:2
21563:3
2157abc:NaN
2158&bceil
2159NaNceil:NaN
2160+inf:inf
2161-inf:-inf
21620:0
2163-1:-1
2164-2:-2
21652:2
21663:3
2167abc:NaN
2168&as_hex
2169128:0x80
2170-128:-0x80
21710:0x0
2172-0:0x0
21731:0x1
21740x123456789123456789:0x123456789123456789
2175+inf:inf
2176-inf:-inf
2177NaNas_hex:NaN
2178&as_bin
2179128:0b10000000
2180-128:-0b10000000
21810:0b0
2182-0:0b0
21831:0b1
21840b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1ddff52a 21850x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001
6854fd01 2186+inf:inf
2187-inf:-inf
2188NaNas_bin:NaN