This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Math::BigInt from 1.999701 to 1.999704
[perl5.git] / cpan / 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();";
06ce15ad
SH
78 # overloaded functions
79 } elsif ($f =~ /^(log|exp|sin|cos|atan2|int|neg|abs|sqrt)$/) {
80 $try .= "\$x = $f(\$x);";
56d9de68
T
81 } elsif ($f =~ /^(numify|length|stringify|as_hex|as_bin)$/) {
82 $try .= "\$x->$f();";
61f5c3f5
T
83 } elsif ($f eq "exponent"){
84 # ->bstr() to see if an object is returned
85 $try .= '$x = $x->exponent()->bstr();';
86 } elsif ($f eq "mantissa"){
87 # ->bstr() to see if an object is returned
88 $try .= '$x = $x->mantissa()->bstr();';
89 } elsif ($f eq "parts"){
90 $try .= '($m,$e) = $x->parts();';
91 # ->bstr() to see if an object is returned
92 $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;';
93 $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
94 $try .= '"$m,$e";';
50109ad0
RGS
95 }elsif ($f eq "bexp"){
96 $try .= "\$x->bexp();";
fdb4b05f
T
97 } elsif ($f eq "bpi"){
98 $try .= "$class\->bpi(\$x);";
61f5c3f5 99 } else {
56d9de68 100 # binary ops
61f5c3f5
T
101 $try .= "\$y = $class->new('$args[1]');";
102 if ($f eq "bcmp")
103 {
a0ac753d 104 $try .= '$x->bcmp($y);';
61f5c3f5 105 } elsif ($f eq "bround") {
6854fd01 106 $try .= "$round_mode; \$x->bround(\$y);";
61f5c3f5
T
107 } elsif ($f eq "bacmp"){
108 $try .= '$x->bacmp($y);';
109 } elsif ($f eq "badd"){
110 $try .= '$x + $y;';
111 } elsif ($f eq "bsub"){
112 $try .= '$x - $y;';
113 } elsif ($f eq "bmul"){
114 $try .= '$x * $y;';
115 } elsif ($f eq "bdiv"){
116 $try .= '$x / $y;';
117 } elsif ($f eq "bdiv-list"){
118 $try .= 'join (",",$x->bdiv($y));';
027dc388 119 # overload via x=
61f5c3f5
T
120 } elsif ($f =~ /^.=$/){
121 $try .= "\$x $f \$y;";
027dc388 122 # overload via x
61f5c3f5
T
123 } elsif ($f =~ /^.$/){
124 $try .= "\$x $f \$y;";
125 } elsif ($f eq "bmod"){
126 $try .= '$x % $y;';
127 } elsif ($f eq "bgcd")
6854fd01
JH
128 {
129 if (defined $args[2])
130 {
61f5c3f5 131 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01
JH
132 }
133 $try .= "$class\::bgcd(\$x, \$y";
134 $try .= ", \$z" if (defined $args[2]);
135 $try .= " );";
136 }
137 elsif ($f eq "blcm")
138 {
139 if (defined $args[2])
140 {
61f5c3f5 141 $try .= " \$z = $class->new('$args[2]'); ";
6854fd01
JH
142 }
143 $try .= "$class\::blcm(\$x, \$y";
144 $try .= ", \$z" if (defined $args[2]);
145 $try .= " );";
146 }elsif ($f eq "blsft"){
147 if (defined $args[2])
148 {
149 $try .= "\$x->blsft(\$y,$args[2]);";
150 }
151 else
152 {
153 $try .= "\$x << \$y;";
154 }
155 }elsif ($f eq "brsft"){
156 if (defined $args[2])
157 {
158 $try .= "\$x->brsft(\$y,$args[2]);";
159 }
160 else
161 {
162 $try .= "\$x >> \$y;";
163 }
50109ad0
RGS
164 }elsif ($f eq "bnok"){
165 $try .= "\$x->bnok(\$y);";
990fb837
RGS
166 }elsif ($f eq "broot"){
167 $try .= "\$x->broot(\$y);";
091c87b1
T
168 }elsif ($f eq "blog"){
169 $try .= "\$x->blog(\$y);";
6854fd01
JH
170 }elsif ($f eq "band"){
171 $try .= "\$x & \$y;";
172 }elsif ($f eq "bior"){
173 $try .= "\$x | \$y;";
174 }elsif ($f eq "bxor"){
175 $try .= "\$x ^ \$y;";
176 }elsif ($f eq "bpow"){
177 $try .= "\$x ** \$y;";
d614cd8b
JH
178 } elsif( $f eq "bmodinv") {
179 $try .= "\$x->bmodinv(\$y);";
6854fd01 180 }elsif ($f eq "digit"){
56b9c951 181 $try .= "\$x->digit(\$y);";
30afc38d
T
182 }elsif ($f eq "batan2"){
183 $try .= "\$x->batan2(\$y);";
d614cd8b 184 } else {
80365507 185 # Functions with three arguments
d614cd8b
JH
186 $try .= "\$z = $class->new(\"$args[2]\");";
187
d614cd8b
JH
188 if( $f eq "bmodpow") {
189 $try .= "\$x->bmodpow(\$y,\$z);";
80365507
T
190 } elsif ($f eq "bmuladd"){
191 $try .= "\$x->bmuladd(\$y,\$z);";
d614cd8b
JH
192 } else { warn "Unknown op '$f'"; }
193 }
61f5c3f5
T
194 } # end else all other ops
195
196 $ans1 = eval $try;
197 # convert hex/binary targets to decimal
198 if ($ans =~ /^(0x0x|0b0b)/)
199 {
200 $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr();
6854fd01 201 }
61f5c3f5
T
202 if ($ans eq "")
203 {
3167abe5 204 is ($ans1, undef);
61f5c3f5
T
205 }
206 else
207 {
208 # print "try: $try ans: $ans1 $ans\n";
3167abe5
NC
209 print "# Tried: '$try'\n" if !is ($ans1, $ans);
210 is (ref($ans),$expected_class) if $expected_class ne $class;
6854fd01 211 }
61f5c3f5
T
212 # check internal state of number objects
213 is_valid($ans1,$f) if ref $ans1;
6854fd01
JH
214 } # endwhile data tests
215close DATA;
216
217# test some more
218@a = ();
219for (my $i = 1; $i < 10; $i++)
220 {
221 push @a, $i;
222 }
3167abe5 223is("@a", "1 2 3 4 5 6 7 8 9");
6854fd01
JH
224
225# test whether self-multiplication works correctly (result is 2**64)
226$try = "\$x = $class->new('4294967296');";
227$try .= '$a = $x->bmul($x);';
228$ans1 = eval $try;
3167abe5 229print "# Tried: '$try'\n" if !is ($ans1, $class->new(2) ** 64);
6854fd01
JH
230# test self-pow
231$try = "\$x = $class->new(10);";
232$try .= '$a = $x->bpow($x);';
233$ans1 = eval $try;
3167abe5 234print "# Tried: '$try'\n" if !is ($ans1, $class->new(10) ** 10);
6854fd01 235
07d34614 236###############################################################################
6854fd01
JH
237# test whether op destroys args or not (should better not)
238
239$x = $class->new(3);
240$y = $class->new(4);
241$z = $x & $y;
3167abe5
NC
242is ($x,3);
243is ($y,4);
244is ($z,0);
6854fd01 245$z = $x | $y;
3167abe5
NC
246is ($x,3);
247is ($y,4);
248is ($z,7);
6854fd01
JH
249$x = $class->new(1);
250$y = $class->new(2);
251$z = $x | $y;
3167abe5
NC
252is ($x,1);
253is ($y,2);
254is ($z,3);
6854fd01
JH
255
256$x = $class->new(5);
257$y = $class->new(4);
258$z = $x ^ $y;
3167abe5
NC
259is ($x,5);
260is ($y,4);
261is ($z,1);
6854fd01
JH
262
263$x = $class->new(-5); $y = -$x;
3167abe5 264is ($x, -5);
6854fd01
JH
265
266$x = $class->new(-5); $y = abs($x);
3167abe5 267is ($x, -5);
6854fd01 268
07d34614
T
269$x = $class->new(8);
270$y = $class->new(-1);
271$z = $class->new(5033);
272my $u = $x->copy()->bmodpow($y,$z);
3167abe5
NC
273is ($u,4404);
274is ($y,-1);
275is ($z,5033);
276
277$x = $class->new(-5); $y = -$x; is ($x,-5); is ($y,5);
278$x = $class->new(-5); $y = $x->copy()->bneg(); is ($x,-5); is ($y,5);
279
280$x = $class->new(-5); $y = $class->new(3); $x->bmul($y); is ($x,-15); is ($y,3);
281$x = $class->new(-5); $y = $class->new(3); $x->badd($y); is ($x,-2); is ($y,3);
282$x = $class->new(-5); $y = $class->new(3); $x->bsub($y); is ($x,-8); is ($y,3);
283$x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); is ($x,-5); is ($y,3);
284$x = $class->new(-5); $y = $class->new(3); $x->bmod($y); is ($x,1); is ($y,3);
285
286$x = $class->new(5); $y = $class->new(3); $x->bmul($y); is ($x,15); is ($y,3);
287$x = $class->new(5); $y = $class->new(3); $x->badd($y); is ($x,8); is ($y,3);
288$x = $class->new(5); $y = $class->new(3); $x->bsub($y); is ($x,2); is ($y,3);
289$x = $class->new(15); $y = $class->new(3); $x->bdiv($y); is ($x,5); is ($y,3);
290$x = $class->new(5); $y = $class->new(3); $x->bmod($y); is ($x,2); is ($y,3);
291
292$x = $class->new(5); $y = $class->new(-3); $x->bmul($y); is ($x,-15); is ($y,-3);
293$x = $class->new(5); $y = $class->new(-3); $x->badd($y); is ($x,2); is ($y,-3);
294$x = $class->new(5); $y = $class->new(-3); $x->bsub($y); is ($x,8); is ($y,-3);
295$x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); is ($x,-5); is ($y,-3);
296$x = $class->new(5); $y = $class->new(-3); $x->bmod($y); is ($x,-1); is ($y,-3);
07d34614
T
297
298###############################################################################
6854fd01
JH
299# check whether overloading cmp works
300$try = "\$x = $class->new(0);";
301$try .= "\$y = 10;";
302$try .= "'false' if \$x ne \$y;";
303$ans = eval $try;
3167abe5 304print "# For '$try'\n" if (!is ("$ans" , "false") );
6854fd01
JH
305
306# we cant test for working cmpt with other objects here, we would need a dummy
307# object with stringify overload for this. see Math::String tests as example
308
309###############################################################################
6854fd01 310# check reversed order of arguments
027dc388 311
6854fd01
JH
312$try = "\$x = $class->new(10); \$x = 2 ** \$x;";
313$try .= "'ok' if \$x == 1024;"; $ans = eval $try;
314print "# For '$try'\n" if (!ok "$ans" , "ok" );
315
316$try = "\$x = $class->new(10); \$x = 2 * \$x;";
317$try .= "'ok' if \$x == 20;"; $ans = eval $try;
318print "# For '$try'\n" if (!ok "$ans" , "ok" );
319
320$try = "\$x = $class->new(10); \$x = 2 + \$x;";
321$try .= "'ok' if \$x == 12;"; $ans = eval $try;
322print "# For '$try'\n" if (!ok "$ans" , "ok" );
323
324$try = "\$x = $class\->new(10); \$x = 2 - \$x;";
325$try .= "'ok' if \$x == -8;"; $ans = eval $try;
326print "# For '$try'\n" if (!ok "$ans" , "ok" );
327
328$try = "\$x = $class\->new(10); \$x = 20 / \$x;";
329$try .= "'ok' if \$x == 2;"; $ans = eval $try;
330print "# For '$try'\n" if (!ok "$ans" , "ok" );
331
027dc388
JH
332$try = "\$x = $class\->new(3); \$x = 20 % \$x;";
333$try .= "'ok' if \$x == 2;"; $ans = eval $try;
334print "# For '$try'\n" if (!ok "$ans" , "ok" );
335
336$try = "\$x = $class\->new(7); \$x = 20 & \$x;";
337$try .= "'ok' if \$x == 4;"; $ans = eval $try;
338print "# For '$try'\n" if (!ok "$ans" , "ok" );
339
340$try = "\$x = $class\->new(7); \$x = 0x20 | \$x;";
341$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
342print "# For '$try'\n" if (!ok "$ans" , "ok" );
343
344$try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;";
345$try .= "'ok' if \$x == 0x27;"; $ans = eval $try;
346print "# For '$try'\n" if (!ok "$ans" , "ok" );
347
6854fd01
JH
348###############################################################################
349# check badd(4,5) form
350
351$try = "\$x = $class\->badd(4,5);";
352$try .= "'ok' if \$x == 9;";
353$ans = eval $try;
354print "# For '$try'\n" if (!ok "$ans" , "ok" );
355
356###############################################################################
357# check undefs: NOT DONE YET
358
359###############################################################################
360# bool
361
3167abe5
NC
362$x = $class->new(1); if ($x) { is (1,1); } else { is ($x,'to be true') }
363$x = $class->new(0); if (!$x) { is (1,1); } else { is ($x,'to be false') }
6854fd01
JH
364
365###############################################################################
366# objectify()
367
368@args = Math::BigInt::objectify(2,4,5);
3167abe5
NC
369is (scalar @args,3); # $class, 4, 5
370like ($args[0], qr/^Math::BigInt/);
371is ($args[1],4);
372is ($args[2],5);
6854fd01
JH
373
374@args = Math::BigInt::objectify(0,4,5);
3167abe5
NC
375is (scalar @args,3); # $class, 4, 5
376like ($args[0], qr/^Math::BigInt/);
377is ($args[1],4);
378is ($args[2],5);
6854fd01
JH
379
380@args = Math::BigInt::objectify(2,4,5);
3167abe5
NC
381is (scalar @args,3); # $class, 4, 5
382like ($args[0], qr/^Math::BigInt/);
383is ($args[1],4);
384is ($args[2],5);
6854fd01
JH
385
386@args = Math::BigInt::objectify(2,4,5,6,7);
3167abe5
NC
387is (scalar @args,5); # $class, 4, 5, 6, 7
388like ($args[0], qr/^Math::BigInt/);
389is ($args[1],4); is (ref($args[1]),$args[0]);
390is ($args[2],5); is (ref($args[2]),$args[0]);
391is ($args[3],6); is (ref($args[3]),'');
392is ($args[4],7); is (ref($args[4]),'');
6854fd01
JH
393
394@args = Math::BigInt::objectify(2,$class,4,5,6,7);
3167abe5
NC
395is (scalar @args,5); # $class, 4, 5, 6, 7
396is ($args[0],$class);
397is ($args[1],4); is (ref($args[1]),$args[0]);
398is ($args[2],5); is (ref($args[2]),$args[0]);
399is ($args[3],6); is (ref($args[3]),'');
400is ($args[4],7); is (ref($args[4]),'');
6854fd01
JH
401
402###############################################################################
f9a08e12
JH
403# test whether an opp calls objectify properly or not (or at least does what
404# it should do given non-objects, w/ or w/o objectify())
405
3167abe5
NC
406is ($class->new(123)->badd(123),246);
407is ($class->badd(123,321),444);
408is ($class->badd(123,$class->new(321)),444);
f9a08e12 409
3167abe5
NC
410is ($class->new(123)->bsub(122),1);
411is ($class->bsub(321,123),198);
412is ($class->bsub(321,$class->new(123)),198);
f9a08e12 413
3167abe5
NC
414is ($class->new(123)->bmul(123),15129);
415is ($class->bmul(123,123),15129);
416is ($class->bmul(123,$class->new(123)),15129);
f9a08e12 417
3167abe5
NC
418is ($class->new(15129)->bdiv(123),123);
419is ($class->bdiv(15129,123),123);
420is ($class->bdiv(15129,$class->new(123)),123);
f9a08e12 421
3167abe5
NC
422is ($class->new(15131)->bmod(123),2);
423is ($class->bmod(15131,123),2);
424is ($class->bmod(15131,$class->new(123)),2);
f9a08e12 425
3167abe5
NC
426is ($class->new(2)->bpow(16),65536);
427is ($class->bpow(2,16),65536);
428is ($class->bpow(2,$class->new(16)),65536);
f9a08e12 429
3167abe5
NC
430is ($class->new(2**15)->brsft(1),2**14);
431is ($class->brsft(2**15,1),2**14);
432is ($class->brsft(2**15,$class->new(1)),2**14);
f9a08e12 433
3167abe5
NC
434is ($class->new(2**13)->blsft(1),2**14);
435is ($class->blsft(2**13,1),2**14);
436is ($class->blsft(2**13,$class->new(1)),2**14);
f9a08e12
JH
437
438###############################################################################
6854fd01
JH
439# test for floating-point input (other tests in bnorm() below)
440
441$z = 1050000000000000; # may be int on systems with 64bit?
3167abe5 442$x = $class->new($z); is ($x->bsstr(),'105e+13'); # not 1.05e+15
6854fd01
JH
443$z = 1e+129; # definitely a float (may fail on UTS)
444# don't compare to $z, since some Perl versions stringify $z into something
445# like '1.e+129' or something equally ugly
3167abe5 446$x = $class->new($z); is ($x->bsstr(),'1e+129');
6854fd01
JH
447
448###############################################################################
9681bfa6 449# test for whitespace including newlines to be handled correctly
56d9de68 450
3167abe5 451# is ($Math::BigInt::strict,1); # the default
56d9de68
T
452
453foreach my $c (
454 qw/1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890/)
455 {
456 my $m = $class->new($c);
3167abe5
NC
457 is ($class->new("$c"),$m);
458 is ($class->new(" $c"),$m);
459 is ($class->new("$c "),$m);
460 is ($class->new(" $c "),$m);
461 is ($class->new("\n$c"),$m);
462 is ($class->new("$c\n"),$m);
463 is ($class->new("\n$c\n"),$m);
464 is ($class->new(" \n$c\n"),$m);
465 is ($class->new(" \n$c \n"),$m);
466 is ($class->new(" \n$c\n "),$m);
467 is ($class->new(" \n$c\n1"),'NaN');
468 is ($class->new("1 \n$c\n1"),'NaN');
56d9de68
T
469 }
470
471###############################################################################
6854fd01
JH
472# prime number tests, also test for **= and length()
473# found on: http://www.utm.edu/research/primes/notes/by_year.html
474
475# ((2^148)-1)/17
476$x = $class->new(2); $x **= 148; $x++; $x = $x / 17;
3167abe5
NC
477is ($x,"20988936657440586486151264256610222593863921");
478is ($x->length(),length "20988936657440586486151264256610222593863921");
6854fd01
JH
479
480# MM7 = 2^127-1
481$x = $class->new(2); $x **= 127; $x--;
3167abe5 482is ($x,"170141183460469231731687303715884105727");
6854fd01
JH
483
484$x = $class->new('215960156869840440586892398248');
485($x,$y) = $x->length();
3167abe5 486is ($x,30); is ($y,0);
6854fd01
JH
487
488$x = $class->new('1_000_000_000_000');
489($x,$y) = $x->length();
3167abe5 490is ($x,13); is ($y,0);
6854fd01 491
2d2b2744
T
492# test <<=, >>=
493$x = $class->new('2');
494my $y = $class->new('18');
3167abe5
NC
495is ($x <<= $y, 2 << 18);
496is ($x, 2 << 18);
497is ($x >>= $y, 2);
498is ($x, 2);
2d2b2744 499
6854fd01
JH
500# I am afraid the following is not yet possible due to slowness
501# Also, testing for 2 meg output is a bit hard ;)
502#$x = $class->new(2); $x **= 6972593; $x--;
503
504# 593573509*2^332162+1 has exactly 1,000,000 digits
505# takes about 24 mins on 300 Mhz, so cannot be done yet ;)
506#$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++;
3167abe5 507#is ($x->length(),1_000_000);
6854fd01
JH
508
509###############################################################################
510# inheritance and overriding of _swap
511
512$x = Math::Foo->new(5);
513$x = $x - 8; # 8 - 5 instead of 5-8
3167abe5
NC
514is ($x,3);
515is (ref($x),'Math::Foo');
6854fd01
JH
516
517$x = Math::Foo->new(5);
518$x = 8 - $x; # 5 - 8 instead of 8 - 5
3167abe5
NC
519is ($x,-3);
520is (ref($x),'Math::Foo');
6854fd01
JH
521
522###############################################################################
523# Test whether +inf eq inf
524# This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl
525# hasn't (before 5.7.3 at least) a consistent way to say inf, and some things
526# like 1e100000 crash on some platforms. So simple test for the string 'inf'
3167abe5 527$x = $class->new('+inf'); is ($x,'inf');
6854fd01
JH
528
529###############################################################################
02916adf
PJA
530# numify() and 64 bit integer support
531
532require Config;
533SKIP: {
534 skip("no 64 bit integer support", 4)
535 unless $Config::Config{use64bitint} || $Config::Config{use64bitall};
536
537 # The following should not give "1.84467440737096e+19".
538
539 $x = $class -> new(2) -> bpow(64) -> bdec();
540 is($x -> bstr(), "18446744073709551615", "bigint 2**64-1 as string");
541 is($x -> numify(), "18446744073709551615", "bigint 2**64-1 as number");
542
543 # The following should not give "-9.22337203685478e+18".
544
545 $x = $class -> new(2) -> bpow(63) -> bneg();
546 is($x -> bstr(), "-9223372036854775808", "bigint -2**63 as string");
547 is($x -> numify(), "-9223372036854775808", "bigint -2**63 as number");
548};
549
550###############################################################################
6854fd01 551###############################################################################
9681bfa6 552# the following tests only make sense with Math::BigInt::Calc or BareCalc or
56d9de68 553# FastCalc
6854fd01 554
06ce15ad
SH
555SKIP: {
556 # skip GMP, Pari et al.
557 skip("skipping tests not intended for the backend $CALC", 50)
558 unless $CALC =~ /^Math::BigInt::(Bare|Fast)?Calc$/;
6854fd01 559
06ce15ad
SH
560 ###########################################################################
561 # check proper length of internal arrays
394e6ffb 562
06ce15ad
SH
563 my $bl = $CL->_base_len();
564 my $BASE = '9' x $bl;
565 my $MAX = $BASE;
566 $BASE++;
6854fd01 567
06ce15ad
SH
568 $x = $class->new($MAX); is_valid($x); # f.i. 9999
569 $x += 1; is ($x,$BASE); is_valid($x); # 10000
570 $x -= 1; is ($x,$MAX); is_valid($x); # 9999 again
6854fd01 571
06ce15ad
SH
572 ###########################################################################
573 # check numify
56b9c951 574
06ce15ad
SH
575 $x = $class->new($BASE-1); is ($x->numify(),$BASE-1);
576 $x = $class->new(-($BASE-1)); is ($x->numify(),-($BASE-1));
56b9c951 577
06ce15ad
SH
578 # +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...)
579 $x = $class->new($BASE); is ($x->numify()+0,$BASE+0);
580 $x = $class->new(-$BASE); is ($x->numify(),-$BASE);
581 $x = $class->new( -($BASE*$BASE*1+$BASE*1+1) );
582 is ($x->numify(),-($BASE*$BASE*1+$BASE*1+1));
6854fd01 583
06ce15ad
SH
584 ###########################################################################
585 # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1
6854fd01 586
06ce15ad
SH
587 $x = $class->new($BASE-2); $x++; $x++; $x++; $x++;
588 if ($x > $BASE) { is (1,1) } else { is ("$x < $BASE","$x > $BASE"); }
61f5c3f5 589
06ce15ad
SH
590 $x = $class->new($BASE+3); $x++;
591 if ($x > $BASE) { is (1,1) } else { is ("$x > $BASE","$x < $BASE"); }
6854fd01 592
06ce15ad
SH
593 # test for +0 instead of int():
594 $x = $class->new($MAX); is ($x->length(), length($MAX));
6854fd01 595
06ce15ad
SH
596 ###########################################################################
597 # test bug that $class->digit($string) did not work
394e6ffb 598
06ce15ad 599 is ($class->digit(123,2),1);
07d34614 600
06ce15ad
SH
601 ###########################################################################
602 # bug in sub where number with at least 6 trailing zeros after any op failed
07d34614 603
06ce15ad
SH
604 $x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z;
605 is ($z, 100000);
606 is ($x, 23456);
56b9c951 607
06ce15ad
SH
608 ###########################################################################
609 # bug in shortcut in mul()
990fb837 610
06ce15ad
SH
611 # construct a number with a zero-hole of BASE_LEN_SMALL
612 {
613 my @bl = $CL->_base_len(); my $bl = $bl[5];
614
615 $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl;
616 $y = '1' x (2*$bl);
617 $x = $class->new($x)->bmul($y);
618 # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl
619 $y = ''; my $d = '';
620 for (my $i = 1; $i <= $bl; $i++)
621 {
622 $y .= $i; $d = $i.$d;
623 }
624 $y .= $bl x (3*$bl-1) . $d . '0' x $bl;
625 is ($x,$y);
626
627
628 #########################################################################
629 # see if mul shortcut for small numbers works
630
631 $x = '9' x $bl;
632 $x = $class->new($x);
633 # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001
634 is ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1');
635 }
990fb837 636
06ce15ad
SH
637 ###########################################################################
638 # bug with rest "-0" in div, causing further div()s to fail
639
640 $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240');
641
642 is ($y,'0'); is_valid($y); # $y not '-0'
643
644 ###########################################################################
645 # bug in $x->bmod($y)
646
647 # if $x < 0 and $y > 0
648 $x = $class->new('-629'); is ($x->bmod(5033),4404);
649
650 ###########################################################################
651 # bone/binf etc as plain calls (Lite failed them)
652
653 is ($class->bzero(),0);
654 is ($class->bone(),1);
655 is ($class->bone('+'),1);
656 is ($class->bone('-'),-1);
657 is ($class->bnan(),'NaN');
658 is ($class->binf(),'inf');
659 is ($class->binf('+'),'inf');
660 is ($class->binf('-'),'-inf');
661 is ($class->binf('-inf'),'-inf');
662
663 ###########################################################################
664 # is_one('-')
665
666 is ($class->new(1)->is_one('-'),0);
667 is ($class->new(-1)->is_one('-'),1);
668 is ($class->new(1)->is_one(),1);
669 is ($class->new(-1)->is_one(),0);
670
671 ###########################################################################
672 # [perl #30609] bug with $x -= $x not being 0, but 2*$x
673
674 $x = $class->new(3); $x -= $x; is ($x, 0);
675 $x = $class->new(-3); $x -= $x; is ($x, 0);
676 $x = $class->new('NaN'); $x -= $x; is ($x->is_nan(), 1);
677 $x = $class->new('inf'); $x -= $x; is ($x->is_nan(), 1);
678 $x = $class->new('-inf'); $x -= $x; is ($x->is_nan(), 1);
679
680 $x = $class->new('NaN'); $x += $x; is ($x->is_nan(), 1);
681 $x = $class->new('inf'); $x += $x; is ($x->is_inf(), 1);
682 $x = $class->new('-inf'); $x += $x; is ($x->is_inf('-'), 1);
683 $x = $class->new(3); $x += $x; is ($x, 6);
684 $x = $class->new(-3); $x += $x; is ($x, -6);
685
686 $x = $class->new(3); $x *= $x; is ($x, 9);
687 $x = $class->new(-3); $x *= $x; is ($x, 9);
688 $x = $class->new(3); $x /= $x; is ($x, 1);
689 $x = $class->new(-3); $x /= $x; is ($x, 1);
690 $x = $class->new(3); $x %= $x; is ($x, 0);
691 $x = $class->new(-3); $x %= $x; is ($x, 0);
692}
03874afe
T
693
694###############################################################################
61f5c3f5 695# all tests done
6854fd01
JH
696
6971;
698
699###############################################################################
6854fd01
JH
700# sub to check validity of a BigInt internally, to ensure that no op leaves a
701# number object in an invalid state (f.i. "-0")
702
703sub is_valid
704 {
705 my ($x,$f) = @_;
706
707 my $e = 0; # error?
6854fd01 708
56b9c951
JH
709 # allow the check to pass for all Lite, and all MBI and subclasses
710 # ok as reference?
711 $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/;
6854fd01 712
56b9c951
JH
713 if (ref($x) ne 'Math::BigInt::Lite')
714 {
715 # has ok sign?
716 $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'"
717 if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/;
718
719 $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0;
720 $e = $CALC->_check($x->{value}) if $e eq '0';
721 }
6854fd01
JH
722
723 # test done, see if error did crop up
3167abe5 724 is (1,1), return if ($e eq '0');
6854fd01 725
3167abe5 726 is (1,$e." after op '$f'");
6854fd01
JH
727 }
728
729__DATA__
027dc388
JH
730&.=
7311234:-345:1234-345
732&+=
7331:2:3
734-1:-2:-3
735&-=
7361:2:-1
737-1:-2:1
738&*=
7392:3:6
740-1:5:-5
741&%=
742100:3:1
7438:9:8
07d34614 744-629:5033:4404
027dc388
JH
745&/=
746100:3:33
747-8:2:-4
748&|=
7492:1:3
750&&=
7515:7:5
752&^=
7535:7:2
091c87b1 754&blog
06ce15ad 755#
091c87b1
T
756NaNlog:2:NaN
757122:NaNlog:NaN
758NaNlog1:NaNlog:NaN
06ce15ad
SH
759#
760122:inf:0
761inf:122:inf
762122:-inf:0
763-inf:122:inf
091c87b1 764-inf:-inf:NaN
06ce15ad 7650:4:-inf
091c87b1
T
766-21:4:NaN
76721:-21:NaN
06ce15ad
SH
768#
7690:-inf:NaN
7700:-1:NaN
7710:0:NaN
7720:1:NaN
7730:inf:NaN
774#
7751:-inf:0
7761:-1:0
7771:0:0
7781:1:NaN
7791:4:0
7801:inf:0
781#
782inf:-inf:NaN
783inf:-1:NaN
784inf:0:NaN
785inf:1:NaN
786inf:4:inf
787inf:inf:NaN
788#
091c87b1
T
789# normal results
7901024:2:10
79181:3:4
792# 3.01.. truncate
79382:3:4
794# 3.9... truncate
79580:3:3
06ce15ad 7964096:2:12
091c87b1
T
79715625:5:6
79815626:5:6
79915624:5:5
8df1e0a2
T
8001000:10:3
80110000:10:4
802100000:10:5
8031000000:10:6
80410000000:10:7
805100000000:10:8
8068916100448256:12:12
8078916100448257:12:12
8088916100448255:12:11
8092251799813685248:8:17
81072057594037927936:2:56
811144115188075855872:2:57
812288230376151711744:2:58
813576460752303423488:2:59
8df1e0a2 8141329227995784915872903807060280344576:2:120
091c87b1
T
815# $x == $base => result 1
8163:3:1
817# $x < $base => result 0 ($base ** 0 <= $x)
8183:4:0
819# $x == 1 => result 0
8201:5:0
6854fd01
JH
821&is_negative
8220:0
823-1:1
8241:0
825+inf:0
826-inf:1
827NaNneg:0
828&is_positive
b68b7ab1 8290:0
6854fd01
JH
830-1:0
8311:1
832+inf:1
833-inf:0
834NaNneg:0
b3abae2a
JH
835&is_int
836-inf:0
837+inf:0
838NaNis_int:0
8391:1
8400:1
841123e12:1
6854fd01
JH
842&is_odd
843abc:0
8440:0
8451:1
8463:1
847-1:1
848-3:1
84910000001:1
85010000002:0
8512:0
b3abae2a
JH
852120:0
853121:1
6854fd01
JH
854&is_even
855abc:0
8560:1
8571:0
8583:0
859-1:0
860-3:0
86110000001:0
86210000002:1
8632:1
b3abae2a
JH
864120:1
865121:0
6854fd01
JH
866&bacmp
867+0:-0:0
868+0:+1:-1
869-1:+1:0
870+1:-1:0
871-1:+2:-1
872+2:-1:1
873-123456789:+987654321:-1
874+123456789:-987654321:-1
875+987654321:+123456789:1
876-987654321:+123456789:1
877-123:+4567889:-1
878# NaNs
879acmpNaN:123:
880123:acmpNaN:
881acmpNaN:acmpNaN:
882# infinity
883+inf:+inf:0
884-inf:-inf:0
885+inf:-inf:0
886-inf:+inf:0
887+inf:123:1
888-inf:123:1
889+inf:-123:1
890-inf:-123:1
ef9466ea
T
891123:-inf:-1
892-123:inf:-1
893-123:-inf:-1
894123:inf:-1
6854fd01
JH
895# return undef
896+inf:NaN:
897NaN:inf:
898-inf:NaN:
899NaN:-inf:
900&bnorm
aef458a0
JH
9010e999:0
9020e-999:0
903-0e999:0
904-0e-999:0
6854fd01
JH
905123:123
906# binary input
9070babc:NaN
9080b123:NaN
9090b0:0
910-0b0:0
911-0b1:-1
9120b0001:1
9130b001:1
9140b011:3
9150b101:5
61f5c3f5
T
9160b1001:9
9170b10001:17
9180b100001:33
9190b1000001:65
9200b10000001:129
9210b100000001:257
9220b1000000001:513
9230b10000000001:1025
9240b100000000001:2049
9250b1000000000001:4097
9260b10000000000001:8193
9270b100000000000001:16385
9280b1000000000000001:32769
9290b10000000000000001:65537
9300b100000000000000001:131073
9310b1000000000000000001:262145
9320b10000000000000000001:524289
9330b100000000000000000001:1048577
9340b1000000000000000000001:2097153
9350b10000000000000000000001:4194305
9360b100000000000000000000001:8388609
9370b1000000000000000000000001:16777217
9380b10000000000000000000000001:33554433
9390b100000000000000000000000001:67108865
9400b1000000000000000000000000001:134217729
9410b10000000000000000000000000001:268435457
9420b100000000000000000000000000001:536870913
9430b1000000000000000000000000000001:1073741825
9440b10000000000000000000000000000001:2147483649
9450b100000000000000000000000000000001:4294967297
9460b1000000000000000000000000000000001:8589934593
9470b10000000000000000000000000000000001:17179869185
de1ac46b 9480b__101:NaN
6854fd01 9490b1_0_1:5
394e6ffb 9500b0_0_0_1:1
6854fd01
JH
951# hex input
952-0x0:0
9530xabcdefgh:NaN
9540x1234:4660
9550xabcdef:11259375
956-0xABCDEF:-11259375
957-0x1234:-4660
9580x12345678:305419896
9590x1_2_3_4_56_78:305419896
394e6ffb 9600xa_b_c_d_e_f:11259375
de1ac46b 9610x__123:NaN
61f5c3f5
T
9620x9:9
9630x11:17
9640x21:33
9650x41:65
9660x81:129
9670x101:257
9680x201:513
9690x401:1025
9700x801:2049
9710x1001:4097
9720x2001:8193
9730x4001:16385
9740x8001:32769
9750x10001:65537
9760x20001:131073
9770x40001:262145
9780x80001:524289
9790x100001:1048577
9800x200001:2097153
9810x400001:4194305
9820x800001:8388609
9830x1000001:16777217
9840x2000001:33554433
9850x4000001:67108865
9860x8000001:134217729
9870x10000001:268435457
9880x20000001:536870913
9890x40000001:1073741825
9900x80000001:2147483649
9910x100000001:4294967297
9920x200000001:8589934593
9930x400000001:17179869185
9940x800000001:34359738369
2d2b2744
T
995# bug found by Mark Lakata in Calc.pm creating too big one-element numbers in _from_hex()
9960x2dd59e18a125dbed30a6ab1d93e9c855569f44f75806f0645dc9a2e98b808c3:1295719234436071846486578237372801883390756472611551858964079371952886122691
6854fd01
JH
997# inf input
998inf:inf
999+inf:inf
1000-inf:-inf
10010inf:NaN
027dc388 1002# abnormal input
6854fd01
JH
1003:NaN
1004abc:NaN
1005 1 a:NaN
10061bcd2:NaN
100711111b:NaN
1008+1z:NaN
1009-1z:NaN
027dc388
JH
1010# only one underscore between two digits
1011_123:NaN
1012_123_:NaN
1013123_:NaN
10141__23:NaN
10151E1__2:NaN
10161_E12:NaN
10171E_12:NaN
10181_E_12:NaN
1019+_1E12:NaN
1020+0_1E2:100
1021+0_0_1E2:100
1022-0_0_1E2:-100
1023-0_0_1E+0_0_2:-100
1024E1:NaN
1025E23:NaN
10261.23E1:NaN
10271.23E-1:NaN
0ac635f7 1028# bug with two E's in number being valid
027dc388
JH
10291e2e3:NaN
10301e2r:NaN
10311e2.0:NaN
0ac635f7 1032# bug with two '.' in number being valid
07d34614
T
10331.2.2:NaN
10341.2.3e1:NaN
1035-1.2.3:NaN
1036-1.2.3e-4:NaN
10371.2e3.4:NaN
10381.2e-3.4:NaN
10391.2.3.4:NaN
10401.2.t:NaN
10411..2:NaN
10421..2e1:NaN
10431..2e1..1:NaN
104412e1..1:NaN
1045..2:NaN
1046.-2:NaN
61f5c3f5
T
1047# leading zeros
1048012:12
10490123:123
105001234:1234
1051012345:12345
10520123456:123456
105301234567:1234567
1054012345678:12345678
10550123456789:123456789
105601234567891:1234567891
1057012345678912:12345678912
10580123456789123:123456789123
105901234567891234:1234567891234
2d2b2744
T
1060# some inputs that result in zero
10610e0:0
1062+0e0:0
1063+0e+0:0
1064-0e+0:0
10650e-0:0
1066-0e-0:0
1067+0e-0:0
1068000:0
106900e2:0
107000e02:0
1071000e002:0
1072000e1230:0
107300e-3:0
107400e+3:0
107500e-03:0
107600e+03:0
1077-000:0
1078-00e2:0
1079-00e02:0
1080-000e002:0
1081-000e1230:0
1082-00e-3:0
1083-00e+3:0
1084-00e-03:0
1085-00e+03:0
027dc388 1086# normal input
6854fd01
JH
10870:0
1088+0:0
1089+00:0
1090+000:0
1091000000000000000000:0
1092-0:0
1093-0000:0
1094+1:1
1095+01:1
1096+001:1
1097+00000100000:100000
1098123456789:123456789
1099-1:-1
1100-01:-1
1101-001:-1
1102-123456789:-123456789
1103-00000100000:-100000
11041_2_3:123
6854fd01
JH
110510000000000E-1_0:1
11061E2:100
11071E1:10
11081E0:1
6854fd01 11091.23E2:123
6854fd01
JH
1110100E-1:10
1111# floating point input
027dc388
JH
1112# .2e2:20
11131.E3:1000
6854fd01
JH
11141.01E2:101
11151010E-1:101
1116-1010E0:-1010
1117-1010E1:-10100
027dc388
JH
11181234.00:1234
1119# non-integer numbers
6854fd01
JH
1120-1010E-2:NaN
1121-1.01E+1:NaN
1122-1.01E-1:NaN
8db29734
PJA
11231E-999999:NaN
11240.5:NaN
6854fd01
JH
1125&bnan
11261:NaN
11272:NaN
1128abc:NaN
1129&bone
61f5c3f5 11302:+:1
6854fd01
JH
11312:-:-1
1132boneNaN:-:-1
61f5c3f5
T
1133boneNaN:+:1
11342:abc:1
11353::1
6854fd01
JH
1136&binf
11371:+:inf
11382:-:-inf
11393:abc:inf
027dc388
JH
1140&is_nan
1141123:0
1142abc:1
1143NaN:1
1144-123:0
6854fd01
JH
1145&is_inf
1146+inf::1
1147-inf::1
1148abc::0
11491::0
1150NaN::0
1151-1::0
1152+inf:-:0
1153+inf:+:1
1154-inf:-:1
1155-inf:+:0
79c55733
JH
1156-inf:-inf:1
1157-inf:+inf:0
1158+inf:-inf:0
1159+inf:+inf:1
6854fd01
JH
1160# it must be exactly /^[+-]inf$/
1161+infinity::0
1162-infinity::0
1163&blsft
1164abc:abc:NaN
61f5c3f5
T
1165+2:+2:8
1166+1:+32:4294967296
1167+1:+48:281474976710656
6854fd01 1168+8:-2:NaN
a9ccbcd7 1169# exercise base 10
6854fd01
JH
1170+12345:4:10:123450000
1171-1234:0:10:-1234
61f5c3f5 1172+1234:0:10:1234
6854fd01
JH
1173+2:2:10:200
1174+12:2:10:1200
1175+1234:-3:10:NaN
11761234567890123:12:10:1234567890123000000000000
b3abae2a
JH
1177-3:1:2:-6
1178-5:1:2:-10
1179-2:1:2:-4
1180-102533203:1:2:-205066406
6854fd01
JH
1181&brsft
1182abc:abc:NaN
61f5c3f5
T
1183+8:+2:2
1184+4294967296:+32:1
1185+281474976710656:+48:1
6854fd01 1186+2:-2:NaN
a9ccbcd7 1187# exercise base 10
6854fd01 1188-1234:0:10:-1234
61f5c3f5 1189+1234:0:10:1234
6854fd01
JH
1190+200:2:10:2
1191+1234:3:10:1
1192+1234:2:10:12
1193+1234:-3:10:NaN
1194310000:4:10:31
119512300000:5:10:123
11961230000000000:10:10:123
119709876123456789067890:12:10:9876123
11981234561234567890123:13:10:123456
b3abae2a
JH
1199820265627:1:2:410132813
1200# test shifting negative numbers in base 2
1201-15:1:2:-8
1202-14:1:2:-7
1203-13:1:2:-7
1204-12:1:2:-6
1205-11:1:2:-6
1206-10:1:2:-5
1207-9:1:2:-5
1208-8:1:2:-4
1209-7:1:2:-4
1210-6:1:2:-3
1211-5:1:2:-3
1212-4:1:2:-2
1213-3:1:2:-2
1214-2:1:2:-1
1215-1:1:2:-1
1216-1640531254:2:2:-410132814
1217-1640531254:1:2:-820265627
1218-820265627:1:2:-410132814
1219-205066405:1:2:-102533203
6854fd01 1220&bsstr
56d9de68
T
1221+inf:inf
1222-inf:-inf
6854fd01
JH
12231e+34:1e+34
1224123.456E3:123456e+0
1225100:1e+2
56d9de68
T
1226bsstrabc:NaN
1227-5:-5e+0
1228-100:-1e+2
1229&numify
1230numifyabc:NaN
1231+inf:inf
1232-inf:-inf
12335:5
1234-5:-5
1235100:100
1236-100:-100
6854fd01
JH
1237&bneg
1238bnegNaN:NaN
1239+inf:-inf
1240-inf:inf
1241abd:NaN
61f5c3f5
T
12420:0
12431:-1
1244-1:1
6854fd01 1245+123456789:-123456789
61f5c3f5 1246-123456789:123456789
6854fd01
JH
1247&babs
1248babsNaN:NaN
1249+inf:inf
1250-inf:inf
61f5c3f5
T
12510:0
12521:1
1253-1:1
1254+123456789:123456789
1255-123456789:123456789
7833bfdd
PJA
1256&bsgn
1257NaN:NaN
1258+inf:1
1259-inf:-1
12600:0
1261+123456789:1
1262-123456789:-1
6854fd01
JH
1263&bcmp
1264bcmpNaN:bcmpNaN:
61f5c3f5
T
1265bcmpNaN:0:
12660:bcmpNaN:
12670:0:0
1268-1:0:-1
12690:-1:1
12701:0:1
12710:1:-1
1272-1:1:-1
12731:-1:1
6854fd01 1274-1:-1:0
61f5c3f5
T
12751:1:0
1276123:123:0
1277123:12:1
127812:123:-1
6854fd01
JH
1279-123:-123:0
1280-123:-12:-1
1281-12:-123:1
61f5c3f5
T
1282123:124:-1
1283124:123:1
6854fd01
JH
1284-123:-124:1
1285-124:-123:-1
61f5c3f5
T
1286100:5:1
1287-123456789:987654321:-1
6854fd01 1288+123456789:-987654321:1
61f5c3f5 1289-987654321:123456789:-1
6854fd01
JH
1290-inf:5432112345:-1
1291+inf:5432112345:1
1292-inf:-5432112345:-1
1293+inf:-5432112345:1
1294+inf:+inf:0
1295-inf:-inf:0
1296+inf:-inf:1
1297-inf:+inf:-1
12985:inf:-1
12995:inf:-1
1300-5:-inf:1
1301-5:-inf:1
1302# return undef
1303+inf:NaN:
1304NaN:inf:
1305-inf:NaN:
1306NaN:-inf:
1307&binc
1308abc:NaN
1309+inf:inf
1310-inf:-inf
61f5c3f5
T
1311+0:1
1312+1:2
1313-1:0
6854fd01
JH
1314&bdec
1315abc:NaN
1316+inf:inf
1317-inf:-inf
1318+0:-1
61f5c3f5 1319+1:0
6854fd01
JH
1320-1:-2
1321&badd
1322abc:abc:NaN
61f5c3f5 1323abc:0:NaN
6854fd01 1324+0:abc:NaN
b3abae2a
JH
1325+inf:-inf:NaN
1326-inf:+inf:NaN
6854fd01
JH
1327+inf:+inf:inf
1328-inf:-inf:-inf
1329baddNaN:+inf:NaN
1330baddNaN:+inf:NaN
1331+inf:baddNaN:NaN
1332-inf:baddNaN:NaN
61f5c3f5
T
13330:0:0
13341:0:1
13350:1:1
13361:1:2
1337-1:0:-1
13380:-1:-1
6854fd01 1339-1:-1:-2
61f5c3f5
T
1340-1:+1:0
1341+1:-1:0
1342+9:+1:10
1343+99:+1:100
1344+999:+1:1000
1345+9999:+1:10000
1346+99999:+1:100000
1347+999999:+1:1000000
1348+9999999:+1:10000000
1349+99999999:+1:100000000
1350+999999999:+1:1000000000
1351+9999999999:+1:10000000000
1352+99999999999:+1:100000000000
1353+10:-1:9
1354+100:-1:99
1355+1000:-1:999
1356+10000:-1:9999
1357+100000:-1:99999
1358+1000000:-1:999999
1359+10000000:-1:9999999
1360+100000000:-1:99999999
1361+1000000000:-1:999999999
1362+10000000000:-1:9999999999
1363+123456789:987654321:1111111110
1364-123456789:987654321:864197532
6854fd01
JH
1365-123456789:-987654321:-1111111110
1366+123456789:-987654321:-864197532
56b9c951
JH
1367-1:10001:10000
1368-1:100001:100000
1369-1:1000001:1000000
1370-1:10000001:10000000
1371-1:100000001:100000000
1372-1:1000000001:1000000000
1373-1:10000000001:10000000000
1374-1:100000000001:100000000000
1375-1:1000000000001:1000000000000
1376-1:10000000000001:10000000000000
1377-1:-10001:-10002
1378-1:-100001:-100002
1379-1:-1000001:-1000002
1380-1:-10000001:-10000002
1381-1:-100000001:-100000002
1382-1:-1000000001:-1000000002
1383-1:-10000000001:-10000000002
1384-1:-100000000001:-100000000002
1385-1:-1000000000001:-1000000000002
1386-1:-10000000000001:-10000000000002
6854fd01
JH
1387&bsub
1388abc:abc:NaN
1389abc:+0:NaN
1390+0:abc:NaN
1391+inf:-inf:inf
1392-inf:+inf:-inf
b3abae2a
JH
1393+inf:+inf:NaN
1394-inf:-inf:NaN
61f5c3f5
T
1395+0:+0:0
1396+1:+0:1
6854fd01 1397+0:+1:-1
61f5c3f5 1398+1:+1:0
6854fd01 1399-1:+0:-1
61f5c3f5
T
1400+0:-1:1
1401-1:-1:0
6854fd01 1402-1:+1:-2
61f5c3f5
T
1403+1:-1:2
1404+9:+1:8
1405+99:+1:98
1406+999:+1:998
1407+9999:+1:9998
1408+99999:+1:99998
1409+999999:+1:999998
1410+9999999:+1:9999998
1411+99999999:+1:99999998
1412+999999999:+1:999999998
1413+9999999999:+1:9999999998
1414+99999999999:+1:99999999998
1415+10:-1:11
1416+100:-1:101
1417+1000:-1:1001
1418+10000:-1:10001
1419+100000:-1:100001
1420+1000000:-1:1000001
1421+10000000:-1:10000001
1422+100000000:-1:100000001
1423+1000000000:-1:1000000001
1424+10000000000:-1:10000000001
6854fd01
JH
1425+123456789:+987654321:-864197532
1426-123456789:+987654321:-1111111110
61f5c3f5
T
1427-123456789:-987654321:864197532
1428+123456789:-987654321:1111111110
56b9c951
JH
142910001:1:10000
1430100001:1:100000
14311000001:1:1000000
143210000001:1:10000000
1433100000001:1:100000000
14341000000001:1:1000000000
143510000000001:1:10000000000
1436100000000001:1:100000000000
14371000000000001:1:1000000000000
143810000000000001:1:10000000000000
143910001:-1:10002
1440100001:-1:100002
14411000001:-1:1000002
144210000001:-1:10000002
1443100000001:-1:100000002
14441000000001:-1:1000000002
144510000000001:-1:10000000002
1446100000000001:-1:100000000002
14471000000000001:-1:1000000000002
144810000000000001:-1:10000000000002
80365507
T
1449&bmuladd
1450abc:abc:0:NaN
1451abc:+0:0:NaN
1452+0:abc:0:NaN
1453+0:0:abc:NaN
1454NaNmul:+inf:0:NaN
1455NaNmul:-inf:0:NaN
1456-inf:NaNmul:0:NaN
1457+inf:NaNmul:0:NaN
1458+inf:+inf:0:inf
1459+inf:-inf:0:-inf
1460-inf:+inf:0:-inf
1461-inf:-inf:0:inf
1462+0:+0:0:0
1463+0:+1:0:0
1464+1:+0:0:0
1465+0:-1:0:0
1466-1:+0:0:0
1467123456789123456789:0:0:0
14680:123456789123456789:0:0
1469-1:-1:0:1
1470-1:-1:0:1
1471-1:+1:0:-1
1472+1:-1:0:-1
1473+1:+1:0:1
1474+2:+3:0:6
1475-2:+3:0:-6
1476+2:-3:0:-6
1477-2:-3:0:6
1478111:111:0:12321
147910101:10101:0:102030201
14801001001:1001001:0:1002003002001
1481100010001:100010001:0:10002000300020001
148210000100001:10000100001:0:100002000030000200001
148311111111111:9:0:99999999999
148422222222222:9:0:199999999998
148533333333333:9:0:299999999997
148644444444444:9:0:399999999996
148755555555555:9:0:499999999995
148866666666666:9:0:599999999994
148977777777777:9:0:699999999993
149088888888888:9:0:799999999992
149199999999999:9:0:899999999991
149211111111111:9:1:100000000000
149322222222222:9:1:199999999999
149433333333333:9:1:299999999998
149544444444444:9:1:399999999997
149655555555555:9:1:499999999996
149766666666666:9:1:599999999995
149877777777777:9:1:699999999994
149988888888888:9:1:799999999993
150099999999999:9:1:899999999992
1501-3:-4:-5:7
15023:-4:-5:-17
1503-3:4:-5:-17
15043:4:-5:7
1505-3:4:5:-7
15063:-4:5:-7
15079999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
15082:3:12345678901234567890:12345678901234567896
6854fd01
JH
1509&bmul
1510abc:abc:NaN
1511abc:+0:NaN
1512+0:abc:NaN
1513NaNmul:+inf:NaN
1514NaNmul:-inf:NaN
1515-inf:NaNmul:NaN
1516+inf:NaNmul:NaN
1517+inf:+inf:inf
1518+inf:-inf:-inf
1519-inf:+inf:-inf
1520-inf:-inf:inf
61f5c3f5
T
1521+0:+0:0
1522+0:+1:0
1523+1:+0:0
1524+0:-1:0
1525-1:+0:0
1526123456789123456789:0:0
15270:123456789123456789:0
1528-1:-1:1
6854fd01
JH
1529-1:+1:-1
1530+1:-1:-1
61f5c3f5
T
1531+1:+1:1
1532+2:+3:6
6854fd01
JH
1533-2:+3:-6
1534+2:-3:-6
61f5c3f5
T
1535-2:-3:6
1536111:111:12321
153710101:10101:102030201
15381001001:1001001:1002003002001
1539100010001:100010001:10002000300020001
154010000100001:10000100001:100002000030000200001
154111111111111:9:99999999999
154222222222222:9:199999999998
154333333333333:9:299999999997
154444444444444:9:399999999996
154555555555555:9:499999999995
154666666666666:9:599999999994
154777777777777:9:699999999993
154888888888888:9:799999999992
154999999999999:9:899999999991
1550+25:+25:625
1551+12345:+12345:152399025
1552+99999:+11111:1111088889
6854fd01
JH
15539999:10000:99990000
155499999:100000:9999900000
1555999999:1000000:999999000000
15569999999:10000000:99999990000000
155799999999:100000000:9999999900000000
1558999999999:1000000000:999999999000000000
15599999999999:10000000000:99999999990000000000
156099999999999:100000000000:9999999999900000000000
1561999999999999:1000000000000:999999999999000000000000
15629999999999999:10000000000000:99999999999990000000000000
156399999999999999:100000000000000:9999999999999900000000000000
1564999999999999999:1000000000000000:999999999999999000000000000000
15659999999999999999:10000000000000000:99999999999999990000000000000000
156699999999999999999:100000000000000000:9999999999999999900000000000000000
1567999999999999999999:1000000000000000000:999999999999999999000000000000000000
15689999999999999999999:10000000000000000000:99999999999999999990000000000000000000
1569&bdiv-list
1570100:20:5,0
15714095:4095:1,0
1572-4095:-4095:1,0
15734095:-4095:-1,0
1574-4095:4095:-1,0
1575123:2:61,1
b3abae2a
JH
15769:5:1,4
15779:4:2,1
6854fd01
JH
1578# inf handling and general remainder
15795:8:0,5
15800:8:0,0
158111:2:5,1
b4a10d33
PJA
158211:-2:-6,-1
1583-11:2:-6,1
6854fd01
JH
1584# see table in documentation in MBI
15850:inf:0,0
15860:-inf:0,0
15875:inf:0,5
b4a10d33
PJA
15885:-inf:-1,-inf
1589-5:inf:-1,inf
6854fd01 1590-5:-inf:0,-5
b4a10d33
PJA
1591inf:5:inf,NaN
1592-inf:5:-inf,NaN
1593inf:-5:-inf,NaN
1594-inf:-5:inf,NaN
6854fd01
JH
15955:5:1,0
1596-5:-5:1,0
b3abae2a
JH
1597inf:inf:NaN,NaN
1598-inf:-inf:NaN,NaN
1599-inf:inf:NaN,NaN
1600inf:-inf:NaN,NaN
6854fd01
JH
16018:0:inf,8
1602inf:0:inf,inf
f603091d 1603# exceptions to remainder rule
6854fd01
JH
1604-8:0:-inf,-8
1605-inf:0:-inf,-inf
b4a10d33 16060:0:NaN,0
990fb837
RGS
1607# test the shortcut in Calc if @$x == @$yorg
16081234567812345678:123456712345678:10,688888898
160912345671234567:1234561234567:10,58888897
1610123456123456:12345123456:10,4888896
16111234512345:123412345:10,388895
16121234567890999999999:1234567890:1000000000,999999999
16131234567890000000000:1234567890:1000000000,0
16141234567890999999999:9876543210:124999998,9503086419
16151234567890000000000:9876543210:124999998,8503086420
161696969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199,484848484848484848484848123012121211954972727272727272727451
7596a890
RGS
1617# bug in v1.76
16181267650600228229401496703205375:1267650600228229401496703205376:0,1267650600228229401496703205375
a9ccbcd7 1619# exercise shortcut for numbers of the same length in div
b68b7ab1
T
1620999999999999999999999999999999999:999999999999999999999999999999999:1,0
1621999999999999999999999999999999999:888888888888888888888888888888888:1,111111111111111111111111111111111
1622999999999999999999999999999999999:777777777777777777777777777777777:1,222222222222222222222222222222222
1623999999999999999999999999999999999:666666666666666666666666666666666:1,333333333333333333333333333333333
1624999999999999999999999999999999999:555555555555555555555555555555555:1,444444444444444444444444444444444
1625999999999999999999999999999999999:444444444444444444444444444444444:2,111111111111111111111111111111111
1626999999999999999999999999999999999:333333333333333333333333333333333:3,0
1627999999999999999999999999999999999:222222222222222222222222222222222:4,111111111111111111111111111111111
1628999999999999999999999999999999999:111111111111111111111111111111111:9,0
16299999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3,0
16309999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3,999999999999999999999
16319999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3,999999999999999999999999999
16329999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4,1999999999999999999999999999
16339999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9,999999999999999999999999999
16349999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99,99999999999999999999999999
16359999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999,9999999999999999999999999
16369999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999,999999999999999999999999
16379999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999,99999999999999999999999
16389999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999,9999999999999999999999
16399999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999,999999999999999999999
6854fd01
JH
1640&bdiv
1641abc:abc:NaN
61f5c3f5
T
1642abc:1:NaN
16431:abc:NaN
16440:0:NaN
6854fd01
JH
1645# inf handling (see table in doc)
16460:inf:0
16470:-inf:0
16485:inf:0
b4a10d33
PJA
16495:-inf:-1
1650-5:inf:-1
6854fd01
JH
1651-5:-inf:0
1652inf:5:inf
1653-inf:5:-inf
1654inf:-5:-inf
1655-inf:-5:inf
16565:5:1
1657-5:-5:1
b3abae2a
JH
1658inf:inf:NaN
1659-inf:-inf:NaN
1660-inf:inf:NaN
1661inf:-inf:NaN
6854fd01
JH
16628:0:inf
1663inf:0:inf
1664-8:0:-inf
1665-inf:0:-inf
16660:0:NaN
166711:2:5
1668-11:-2:5
b4a10d33
PJA
1669-11:2:-6
167011:-2:-6
61f5c3f5
T
16710:1:0
16720:-1:0
16731:1:1
1674-1:-1:1
16751:-1:-1
1676-1:1:-1
16771:2:0
16782:1:2
16791:26:0
16801000000000:9:111111111
16812000000000:9:222222222
16823000000000:9:333333333
16834000000000:9:444444444
16845000000000:9:555555555
16856000000000:9:666666666
16867000000000:9:777777777
16878000000000:9:888888888
16889000000000:9:1000000000
168935500000:113:314159
169071000000:226:314159
1691106500000:339:314159
16921000000000:3:333333333
1693+10:+5:2
1694+100:+4:25
1695+1000:+8:125
1696+10000:+16:625
1697999999999999:9:111111111111
1698999999999999:99:10101010101
1699999999999999:999:1001001001
1700999999999999:9999:100010001
1701999999999999999:99999:10000100001
1702+1111088889:99999:11111
6854fd01 1703-5:-3:1
b4a10d33 1704-5:3:-2
6854fd01 17054:3:1
b4a10d33 17064:-3:-2
6854fd01 17071:3:0
b4a10d33 17081:-3:-1
6854fd01 1709-2:-3:0
b4a10d33 1710-2:3:-1
6854fd01 17118:3:2
b4a10d33
PJA
1712-8:3:-3
171314:-3:-5
1714-14:3:-5
6854fd01
JH
1715-14:-3:4
171614:3:4
1717# bug in Calc with '99999' vs $BASE-1
171810000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
990fb837
RGS
1719# test the shortcut in Calc if @$x == @$yorg
17201234567812345678:123456712345678:10
172112345671234567:1234561234567:10
1722123456123456:12345123456:10
17231234512345:123412345:10
17241234567890999999999:1234567890:1000000000
17251234567890000000000:1234567890:1000000000
17261234567890999999999:9876543210:124999998
17271234567890000000000:9876543210:124999998
172896969696969696969696969696969678787878626262626262626262626262:484848484848484848484848486666666666666689898989898989898989:199
aef458a0
JH
1729# bug up to v0.35 in Calc (--$q one too many)
173084696969696969696956565656566184292929292929292847474747436308080808080808086765396464646464646465:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999999
173184696969696969696943434343434871161616161616161452525252486813131313131313143230042929292929292930:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999998
173284696969696969696969696969697497424242424242424242424242385803030303030303030300750000000000000000:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6450000000000000000
173384696969696969696930303030303558030303030303030057575757537318181818181818199694689393939393939395:13131313131313131313131313131394949494949494949494949494943535353535353535353535:6449999999999999997
c4a6f826 1734# exercise shortcut for numbers of the same length in div
b68b7ab1
T
1735999999999999999999999999999999999:999999999999999999999999999999999:1
1736999999999999999999999999999999999:888888888888888888888888888888888:1
1737999999999999999999999999999999999:777777777777777777777777777777777:1
1738999999999999999999999999999999999:666666666666666666666666666666666:1
1739999999999999999999999999999999999:555555555555555555555555555555555:1
1740999999999999999999999999999999999:444444444444444444444444444444444:2
1741999999999999999999999999999999999:333333333333333333333333333333333:3
1742999999999999999999999999999999999:222222222222222222222222222222222:4
1743999999999999999999999999999999999:111111111111111111111111111111111:9
17449999999_9999999_9999999_9999999:3333333_3333333_3333333_3333333:3
17459999999_9999999_9999999_9999999:3333333_0000000_0000000_0000000:3
17469999999_9999999_9999999_9999999:3000000_0000000_0000000_0000000:3
17479999999_9999999_9999999_9999999:2000000_0000000_0000000_0000000:4
17489999999_9999999_9999999_9999999:1000000_0000000_0000000_0000000:9
17499999999_9999999_9999999_9999999:100000_0000000_0000000_0000000:99
17509999999_9999999_9999999_9999999:10000_0000000_0000000_0000000:999
17519999999_9999999_9999999_9999999:1000_0000000_0000000_0000000:9999
17529999999_9999999_9999999_9999999:100_0000000_0000000_0000000:99999
17539999999_9999999_9999999_9999999:10_0000000_0000000_0000000:999999
17549999999_9999999_9999999_9999999:1_0000000_0000000_0000000:9999999
a87115f0
RGS
1755# bug with shortcut in Calc 0.44
1756949418181818187070707070707070707070:181818181853535353535353535353535353:5
07d34614
T
1757&bmodinv
1758# format: number:modulus:result
1759# bmodinv Data errors
1760abc:abc:NaN
1761abc:5:NaN
17625:abc:NaN
1763# bmodinv Expected Results from normal use
17641:5:1
17653:5:2
487de07a 17663:-5:-3
07d34614
T
1767-2:5:2
17688:5033:4404
56d9de68
T
17691234567891:13:6
1770-1234567891:13:7
07d34614 1771324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902
116f6d6b
PJA
1772-2:1:0
1773-1:1:0
17740:1:0
17751:1:0
17762:1:0
17773:1:0
17784:1:0
1779-2:3:1
1780-1:3:2
17810:3:NaN
17821:3:1
17832:3:2
17843:3:NaN
17854:3:1
1786-2:4:NaN
1787-1:4:3
17880:4:NaN
17891:4:1
17902:4:NaN
17913:4:3
17924:4:NaN
d614cd8b 1793## bmodinv Error cases / useless use of function
07d34614 1794inf:5:NaN
1ddff52a
JH
17955:inf:NaN
1796-inf:5:NaN
17975:-inf:NaN
07d34614
T
1798&bmodpow
1799# format: number:exponent:modulus:result
1800# bmodpow Data errors
1801abc:abc:abc:NaN
18025:abc:abc:NaN
1803abc:5:abc:NaN
1804abc:abc:5:NaN
18055:5:abc:NaN
18065:abc:5:NaN
1807abc:5:5:NaN
b4a10d33 18083:5:0:3
07d34614
T
1809# bmodpow Expected results
18100:0:2:1
18111:0:2:1
3a7a056a 18120:3:5:0
116f6d6b
PJA
1813-2:-2:1:0
1814-1:-2:1:0
18150:-2:1:0
18161:-2:1:0
18172:-2:1:0
18183:-2:1:0
18194:-2:1:0
1820-2:-1:1:0
1821-1:-1:1:0
18220:-1:1:0
18231:-1:1:0
18242:-1:1:0
18253:-1:1:0
18264:-1:1:0
1827-2:0:1:0
1828-1:0:1:0
18290:0:1:0
18301:0:1:0
18312:0:1:0
18323:0:1:0
18334:0:1:0
1834-2:1:1:0
1835-1:1:1:0
18360:1:1:0
18371:1:1:0
18382:1:1:0
18393:1:1:0
18404:1:1:0
1841-2:2:1:0
1842-1:2:1:0
18430:2:1:0
18441:2:1:0
18452:2:1:0
18463:2:1:0
18474:2:1:0
1848-2:3:1:0
1849-1:3:1:0
18500:3:1:0
18511:3:1:0
18522:3:1:0
18533:3:1:0
18544:3:1:0
1855-2:4:1:0
1856-1:4:1:0
18570:4:1:0
18581:4:1:0
18592:4:1:0
18603:4:1:0
18614:4:1:0
1862-2:-2:3:1
1863-1:-2:3:1
18640:-2:3:NaN
18651:-2:3:1
18662:-2:3:1
18673:-2:3:NaN
18684:-2:3:1
1869-2:-1:3:1
1870-1:-1:3:2
18710:-1:3:NaN
18721:-1:3:1
18732:-1:3:2
18743:-1:3:NaN
18754:-1:3:1
1876-2:0:3:1
1877-1:0:3:1
18780:0:3:1
18791:0:3:1
18802:0:3:1
18813:0:3:1
18824:0:3:1
1883-2:1:3:1
1884-1:1:3:2
18850:1:3:0
18861:1:3:1
18872:1:3:2
18883:1:3:0
18894:1:3:1
1890-2:2:3:1
1891-1:2:3:1
18920:2:3:0
18931:2:3:1
18942:2:3:1
18953:2:3:0
18964:2:3:1
1897-2:3:3:1
1898-1:3:3:2
18990:3:3:0
19001:3:3:1
19012:3:3:2
19023:3:3:0
19034:3:3:1
1904-2:4:3:1
1905-1:4:3:1
19060:4:3:0
19071:4:3:1
19082:4:3:1
19093:4:3:0
19104:4:3:1
1911-2:-2:4:NaN
1912-1:-2:4:1
19130:-2:4:NaN
19141:-2:4:1
19152:-2:4:NaN
19163:-2:4:1
19174:-2:4:NaN
1918-2:-1:4:NaN
1919-1:-1:4:3
19200:-1:4:NaN
19211:-1:4:1
19222:-1:4:NaN
19233:-1:4:3
19244:-1:4:NaN
1925-2:0:4:1
1926-1:0:4:1
19270:0:4:1
19281:0:4:1
19292:0:4:1
19303:0:4:1
19314:0:4:1
1932-2:1:4:2
1933-1:1:4:3
19340:1:4:0
19351:1:4:1
19362:1:4:2
19373:1:4:3
19384:1:4:0
1939-2:2:4:0
1940-1:2:4:1
19410:2:4:0
19421:2:4:1
19432:2:4:0
19443:2:4:1
19454:2:4:0
1946-2:3:4:0
1947-1:3:4:3
19480:3:4:0
19491:3:4:1
19502:3:4:0
19513:3:4:3
19524:3:4:0
1953-2:4:4:0
1954-1:4:4:1
19550:4:4:0
19561:4:4:1
19572:4:4:0
19583:4:4:1
19594:4:4:0
19608:-1:16:NaN
07d34614 19618:-1:5033:4404
116f6d6b
PJA
19628:7:5032:3840
19638:8:-5:-4
ddb27680 19641e50:1:1:0
07d34614
T
196598436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518
1966# bmodpow Error cases
07d34614
T
1967inf:5:13:NaN
19685:inf:13:NaN
6854fd01
JH
1969&bmod
1970# inf handling, see table in doc
19710:inf:0
19720:-inf:0
19735:inf:5
b4a10d33
PJA
19745:-inf:-inf
1975-5:inf:inf
6854fd01 1976-5:-inf:-5
b4a10d33
PJA
1977inf:5:NaN
1978-inf:5:NaN
1979inf:-5:NaN
1980-inf:-5:NaN
6854fd01
JH
19815:5:0
1982-5:-5:0
b3abae2a
JH
1983inf:inf:NaN
1984-inf:-inf:NaN
1985-inf:inf:NaN
1986inf:-inf:NaN
6854fd01
JH
19878:0:8
1988inf:0:inf
6854fd01
JH
1989-inf:0:-inf
1990-8:0:-8
b4a10d33 19910:0:0
6854fd01 1992abc:abc:NaN
61f5c3f5
T
1993abc:1:abc:NaN
19941:abc:NaN
61f5c3f5
T
19950:1:0
19961:0:1
19970:-1:0
1998-1:0:-1
19991:1:0
2000-1:-1:0
20011:-1:0
2002-1:1:0
20031:2:1
20042:1:0
20051000000000:9:1
20062000000000:9:2
20073000000000:9:3
20084000000000:9:4
20095000000000:9:5
20106000000000:9:6
20117000000000:9:7
20128000000000:9:8
20139000000000:9:0
201435500000:113:33
201571000000:226:66
2016106500000:339:99
20171000000000:3:1
201810:5:0
2019100:4:0
20201000:8:0
202110000:16:0
2022999999999999:9:0
2023999999999999:99:0
2024999999999999:999:0
2025999999999999:9999:0
2026999999999999999:99999:0
2027-9:+5:1
6854fd01
JH
2028+9:-5:-1
2029-9:-5:-4
2030-5:3:1
2031-2:3:1
20324:3:1
20331:3:1
2034-5:-3:-2
2035-2:-3:-2
20364:-3:-2
20371:-3:-2
20384095:4095:0
027dc388
JH
2039100041000510123:3:0
2040152403346:12345:4321
b3abae2a 20419:5:4
28df3e88
JH
2042# test shortcuts in Calc
2043# 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0
20441234:9:1
2045123456:9:3
204612345678:9:0
20471234567891:9:1
2048123456789123:9:6
204912345678912345:9:6
20501234567891234567:9:1
2051123456789123456789:9:0
20521234:10:4
2053123456:10:6
205412345678:10:8
20551234567891:10:1
2056123456789123:10:3
205712345678912345:10:5
20581234567891234567:10:7
2059123456789123456789:10:9
20601234:113:104
2061123456:113:60
206212345678:113:89
20631234567891:113:64
2064123456789123:113:95
206512345678912345:113:53
20661234567891234567:113:56
2067123456789123456789:113:39
07d34614
T
2068# bug in bmod() not modifying the variable in place
2069-629:5033:4404
aef458a0
JH
2070# bug in bmod() in Calc in the _div_use_div() shortcut code path,
2071# when X == X and X was big
2072111111111111111111111111111111:111111111111111111111111111111:0
207312345678901234567890:12345678901234567890:0
6854fd01 2074&bgcd
9b924220
RGS
2075inf:12:NaN
2076-inf:12:NaN
207712:inf:NaN
207812:-inf:NaN
2079inf:inf:NaN
2080inf:-inf:NaN
2081-inf:-inf:NaN
6854fd01
JH
2082abc:abc:NaN
2083abc:+0:NaN
2084+0:abc:NaN
61f5c3f5
T
2085+0:+0:0
2086+0:+1:1
2087+1:+0:1
2088+1:+1:1
2089+2:+3:1
2090+3:+2:1
2091-3:+2:1
9b924220
RGS
2092-3:-2:1
2093-144:-60:12
2094144:-60:12
2095144:60:12
61f5c3f5
T
2096100:625:25
20974096:81:1
20981034:804:2
209927:90:56:1
210027:90:54:9
6854fd01
JH
2101&blcm
2102abc:abc:NaN
2103abc:+0:NaN
2104+0:abc:NaN
2105+0:+0:NaN
61f5c3f5
T
2106+1:+0:0
2107+0:+1:0
2108+27:+90:270
2109+1034:+804:415668
6854fd01
JH
2110&band
2111abc:abc:NaN
2112abc:0:NaN
21130:abc:NaN
21141:2:0
21153:2:2
61f5c3f5
T
2116+8:+2:0
2117+281474976710656:0:0
2118+281474976710656:1:0
2119+281474976710656:+281474976710656:281474976710656
9b924220 2120281474976710656:-1:281474976710656
6854fd01
JH
2121-2:-3:-4
2122-1:-1:-1
2123-6:-6:-6
2124-7:-4:-8
2125-7:4:0
2126-4:7:4
9b924220
RGS
2127# negative argument is bitwise shorter than positive [perl #26559]
212830:-3:28
2129123:-1:123
394e6ffb
JH
2130# equal arguments are treated special, so also do some test with unequal ones
21310xFFFF:0xFFFF:0x0xFFFF
21320xFFFFFF:0xFFFFFF:0x0xFFFFFF
21330xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
21340xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21350xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21360xF0F0:0xF0F0:0x0xF0F0
21370x0F0F:0x0F0F:0x0x0F0F
21380xF0F0F0:0xF0F0F0:0x0xF0F0F0
21390x0F0F0F:0x0F0F0F:0x0x0F0F0F
21400xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
21410x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
21420xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
21430x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
21440xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
21450x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
21460x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F
6854fd01
JH
2147&bior
2148abc:abc:NaN
2149abc:0:NaN
21500:abc:NaN
21511:2:3
61f5c3f5
T
2152+8:+2:10
2153+281474976710656:0:281474976710656
2154+281474976710656:1:281474976710657
2155+281474976710656:281474976710656:281474976710656
6854fd01
JH
2156-2:-3:-1
2157-1:-1:-1
2158-6:-6:-6
2159-7:4:-3
2160-4:7:-1
9b924220
RGS
2161+281474976710656:-1:-1
216230:-3:-1
216330:-4:-2
2164300:-76:-68
2165-76:300:-68
394e6ffb
JH
2166# equal arguments are treated special, so also do some test with unequal ones
21670xFFFF:0xFFFF:0x0xFFFF
21680xFFFFFF:0xFFFFFF:0x0xFFFFFF
21690xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF
21700xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21710xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21720:0xFFFF:0x0xFFFF
21730:0xFFFFFF:0x0xFFFFFF
21740:0xFFFFFFFF:0x0xFFFFFFFF
21750:0xFFFFFFFFFF:0x0xFFFFFFFFFF
21760:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
21770xFFFF:0:0x0xFFFF
21780xFFFFFF:0:0x0xFFFFFF
21790xFFFFFFFF:0:0x0xFFFFFFFF
21800xFFFFFFFFFF:0:0x0xFFFFFFFFFF
21810xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
21820xF0F0:0xF0F0:0x0xF0F0
21830x0F0F:0x0F0F:0x0x0F0F
21840xF0F0:0x0F0F:0x0xFFFF
21850xF0F0F0:0xF0F0F0:0x0xF0F0F0
21860x0F0F0F:0x0F0F0F:0x0x0F0F0F
21870x0F0F0F:0xF0F0F0:0x0xFFFFFF
21880xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0
21890x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F
21900x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
21910xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0
21920x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F
21930x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
21940xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0
21950x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F
21960x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
21970x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01
JH
2198&bxor
2199abc:abc:NaN
2200abc:0:NaN
22010:abc:NaN
22021:2:3
61f5c3f5
T
2203+8:+2:10
2204+281474976710656:0:281474976710656
2205+281474976710656:1:281474976710657
2206+281474976710656:281474976710656:0
6854fd01
JH
2207-2:-3:3
2208-1:-1:0
2209-6:-6:0
2210-7:4:-3
2211-4:7:-5
22124:-7:-3
2213-4:-7:5
9b924220
RGS
221430:-3:-29
221530:-4:-30
2216300:-76:-360
2217-76:300:-360
394e6ffb
JH
2218# equal arguments are treated special, so also do some test with unequal ones
22190xFFFF:0xFFFF:0
22200xFFFFFF:0xFFFFFF:0
22210xFFFFFFFF:0xFFFFFFFF:0
22220xFFFFFFFFFF:0xFFFFFFFFFF:0
22230xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0
22240:0xFFFF:0x0xFFFF
22250:0xFFFFFF:0x0xFFFFFF
22260:0xFFFFFFFF:0x0xFFFFFFFF
22270:0xFFFFFFFFFF:0x0xFFFFFFFFFF
22280:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF
22290xFFFF:0:0x0xFFFF
22300xFFFFFF:0:0x0xFFFFFF
22310xFFFFFFFF:0:0x0xFFFFFFFF
22320xFFFFFFFFFF:0:0x0xFFFFFFFFFF
22330xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF
22340xF0F0:0xF0F0:0
22350x0F0F:0x0F0F:0
22360xF0F0:0x0F0F:0x0xFFFF
22370xF0F0F0:0xF0F0F0:0
22380x0F0F0F:0x0F0F0F:0
22390x0F0F0F:0xF0F0F0:0x0xFFFFFF
22400xF0F0F0F0:0xF0F0F0F0:0
22410x0F0F0F0F:0x0F0F0F0F:0
22420x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF
22430xF0F0F0F0F0:0xF0F0F0F0F0:0
22440x0F0F0F0F0F:0x0F0F0F0F0F:0
22450x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF
22460xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0
22470x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0
22480x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF
6854fd01
JH
2249&bnot
2250abc:NaN
2251+0:-1
2252+8:-9
2253+281474976710656:-281474976710657
2254-1:0
2255-2:1
2256-12:11
2257&digit
22580:0:0
225912:0:2
226012:1:1
2261123:0:3
2262123:1:2
2263123:2:1
2264123:-1:1
2265123:-2:2
2266123:-3:3
2267123456:0:6
2268123456:1:5
2269123456:2:4
2270123456:3:3
2271123456:4:2
2272123456:5:1
2273123456:-1:1
2274123456:-2:2
2275123456:-3:3
2276100000:-3:0
2277100000:0:0
2278100000:1:0
2279&mantissa
2280abc:NaN
22811e4:1
22822e0:2
2283123:123
2284-1:-1
2285-2:-2
2286+inf:inf
2287-inf:-inf
2288&exponent
2289abc:NaN
22901e4:4
22912e0:0
2292123:0
2293-1:0
2294-2:0
22950:1
2296+inf:inf
2297-inf:inf
2298&parts
2299abc:NaN,NaN
23001e4:1,4
23012e0:2,0
2302123:123,0
2303-1:-1,0
2304-2:-2,0
23050:0,1
2306+inf:inf,inf
2307-inf:-inf,inf
b3abae2a
JH
2308&bfac
2309-1:NaN
2310NaNfac:NaN
b282a552 2311+inf:inf
b3abae2a
JH
2312-inf:NaN
23130:1
23141:1
23152:2
23163:6
23174:24
23185:120
23196:720
990fb837
RGS
23207:5040
23218:40320
23229:362880
b3abae2a
JH
232310:3628800
232411:39916800
232512:479001600
50109ad0
RGS
232620:2432902008176640000
232722:1124000727777607680000
232869:171122452428141311372468338881272839092270544893520369393648040923257279754140647424000000000000000
6854fd01
JH
2329&bpow
2330abc:12:NaN
233112:abc:NaN
23320:0:1
23330:1:0
23340:2:0
9b924220
RGS
23350:-1:inf
23360:-2:inf
6854fd01
JH
23371:0:1
23381:1:1
23391:2:1
23401:3:1
23411:-1:1
23421:-2:1
23431:-3:1
23442:0:1
23452:1:2
23462:2:4
23472:3:8
23483:3:27
2d2b2744
T
2349-2:2:4
2350-2:3:-8
2351-2:4:16
2352-2:5:-32
6854fd01
JH
23532:-1:NaN
2354-2:-1:NaN
23552:-2:NaN
2356-2:-2:NaN
2d2b2744 2357# inf tests
6854fd01 2358+inf:1234500012:inf
2d2b2744
T
2359-inf:1234500012:inf
2360-inf:1234500013:-inf
6854fd01
JH
2361+inf:-12345000123:inf
2362-inf:-12345000123:-inf
2d2b2744
T
2363# -inf * -inf = inf
2364-inf:2:inf
2365-inf:0:NaN
2366-inf:-1:0
2367-inf:inf:NaN
23682:inf:inf
23692:-inf:0
23700:inf:0
23710:-inf:inf
2372-1:-inf:NaN
2373-1:inf:NaN
2374-2:inf:NaN
2375-2:-inf:0
2376NaN:inf:NaN
2377NaN:-inf:NaN
2378-inf:NaN:NaN
2379inf:NaN:NaN
2380inf:-inf:NaN
23811:inf:1
23821:-inf:1
6854fd01
JH
2383# 1 ** -x => 1 / (1 ** x)
2384-1:0:1
2385-2:0:1
2386-1:1:-1
2387-1:2:1
2388-1:3:-1
2389-1:4:1
2390-1:5:-1
2391-1:-1:-1
2392-1:-2:1
2393-1:-3:-1
2394-1:-4:1
239510:2:100
239610:3:1000
239710:4:10000
239810:5:100000
239910:6:1000000
240010:7:10000000
240110:8:100000000
240210:9:1000000000
240310:20:100000000000000000000
2404123456:2:15241383936
9b924220
RGS
2405-2:2:4
2406-2:3:-8
2407-2:4:16
2408-2:5:-32
2409-3:2:9
2410-3:3:-27
2411-3:4:81
2412-3:5:-243
6854fd01
JH
2413&length
2414100:3
241510:2
24161:1
24170:1
241812345:5
241910000000000000000:17
2420-123:3
2421215960156869840440586892398248:30
990fb837
RGS
2422&broot
2423# sqrt()
2424+0:2:0
2425+1:2:1
2426-1:2:NaN
2427# -$x ** (1/2) => -$y, but not in froot()
2428-123:2:NaN
2429+inf:2:inf
2430-inf:2:NaN
24312:2:1
2432-2:2:NaN
24334:2:2
24349:2:3
243516:2:4
2436100:2:10
2437123:2:11
243815241:2:123
2439144:2:12
244012:2:3
990fb837
RGS
2441# invalid ones
24421:NaN:NaN
2443-1:NaN:NaN
24440:NaN:NaN
2445-inf:NaN:NaN
2446+inf:NaN:NaN
2447NaN:0:NaN
2448NaN:2:NaN
2449NaN:inf:NaN
2450NaN:inf:NaN
245112:-inf:NaN
245212:inf:NaN
2453+0:0:NaN
2454+1:0:NaN
2455-1:0:NaN
2456-2:0:NaN
2457-123.45:0:NaN
2458+inf:0:NaN
245912:1:12
2460-12:1:NaN
24618:-1:NaN
2462-8:-1:NaN
2463# cubic root
24648:3:2
2465-8:3:NaN
2466# fourths root
c38b2de2
JH
246716:4:2
246881:4:3
3a427a11 2469# 2 ** 64
c38b2de2
JH
247018446744073709551616:4:65536
247118446744073709551616:8:256
247218446744073709551616:16:16
247318446744073709551616:32:4
247418446744073709551616:64:2
247518446744073709551616:128:1
3a427a11
RGS
2476# 213 ** 15
247784274086103068221283760416414557757:15:213
50109ad0 2478# see t/bigroot.t for more tests
6854fd01 2479&bsqrt
394e6ffb 2480145:12
6854fd01 2481144:12
394e6ffb 2482143:11
6854fd01 248316:4
394e6ffb
JH
2484170:13
2485169:13
2486168:12
6854fd01 24874:2
394e6ffb 24883:1
6854fd01 24892:1
394e6ffb 24909:3
6854fd01
JH
249112:3
2492256:16
2493100000000:10000
24944000000000000:2000000
394e6ffb
JH
2495152399026:12345
2496152399025:12345
2497152399024:12344
3a427a11
RGS
2498# 2 ** 64 => 2 ** 32
249918446744073709551616:4294967296
250084274086103068221283760416414557757:290299993288095377
6854fd01
JH
25011:1
25020:0
2503-2:NaN
394e6ffb 2504-123:NaN
6854fd01 2505Nan:NaN
990fb837
RGS
2506+inf:inf
2507-inf:NaN
50109ad0
RGS
2508# see t/biglog.t for more tests
2509&bexp
2510NaN:NaN
2511inf:inf
25121:2
25132:7
30afc38d
T
2514&batan2
2515NaN:1:10:NaN
2516NaN:NaN:10:NaN
25171:NaN:10:NaN
2518inf:1:14:1
2519-inf:1:14:-1
0dceeee6
RGS
25200:-inf:14:3
2521-1:-inf:14:-3
25221:-inf:14:3
25230:inf:14:0
2524inf:-inf:14:2
2525-inf:-inf:14:-2
2526# +- 0.78....
2527inf:+inf:14:0
2528-inf:+inf:14:0
30afc38d
T
25291:5:13:0
25301:5:14:0
25310:0:10:0
25320:1:14:0
25330:2:14:0
25341:0:14:1
25355:0:14:1
2536-1:0:11:-1
2537-2:0:77:-1
25382:0:77:1
2539-1:5:14:0
25401:5:14:0
2541-1:8:14:0
25421:8:14:0
2543-1:1:14:0
fdb4b05f
T
2544&bpi
254577:3
2546+0:3
254711:3
50109ad0
RGS
2548# see t/bignok.t for more tests
2549&bnok
2550+inf:10:inf
2551NaN:NaN:NaN
2552NaN:1:NaN
25531:NaN:NaN
25541:1:1
2555# k > n
25561:2:0
25572:3:0
2558# k < 0
25591:-2:0
2560# 7 over 3 = 35
25617:3:35
d5735945 25627:6:7
50109ad0
RGS
2563100:90:17310309456440
2564100:95:75287520
d5735945
PF
25652:0:1
25667:0:1
25672:1:2
6854fd01
JH
2568&bround
2569$round_mode('trunc')
25700:12:0
2571NaNbround:12:NaN
2572+inf:12:inf
2573-inf:12:-inf
25741234:0:1234
25751234:2:1200
2576123456:4:123400
2577123456:5:123450
2578123456:6:123456
61f5c3f5 2579+10123456789:5:10123000000
6854fd01 2580-10123456789:5:-10123000000
61f5c3f5 2581+10123456789:9:10123456700
6854fd01 2582-10123456789:9:-10123456700
61f5c3f5 2583+101234500:6:101234000
6854fd01 2584-101234500:6:-101234000
61f5c3f5 2585#+101234500:-4:101234000
6854fd01
JH
2586#-101234500:-4:-101234000
2587$round_mode('zero')
61f5c3f5 2588+20123456789:5:20123000000
6854fd01 2589-20123456789:5:-20123000000
61f5c3f5 2590+20123456789:9:20123456800
6854fd01 2591-20123456789:9:-20123456800
61f5c3f5 2592+201234500:6:201234000
6854fd01 2593-201234500:6:-201234000
61f5c3f5 2594#+201234500:-4:201234000
6854fd01
JH
2595#-201234500:-4:-201234000
2596+12345000:4:12340000
2597-12345000:4:-12340000
2598$round_mode('+inf')
61f5c3f5 2599+30123456789:5:30123000000
6854fd01 2600-30123456789:5:-30123000000
61f5c3f5 2601+30123456789:9:30123456800
6854fd01 2602-30123456789:9:-30123456800
61f5c3f5 2603+301234500:6:301235000
6854fd01 2604-301234500:6:-301234000
61f5c3f5 2605#+301234500:-4:301235000
6854fd01
JH
2606#-301234500:-4:-301234000
2607+12345000:4:12350000
2608-12345000:4:-12340000
2609$round_mode('-inf')
61f5c3f5 2610+40123456789:5:40123000000
6854fd01 2611-40123456789:5:-40123000000
61f5c3f5 2612+40123456789:9:40123456800
6854fd01 2613-40123456789:9:-40123456800
61f5c3f5
T
2614+401234500:6:401234000
2615+401234500:6:401234000
6854fd01
JH
2616#-401234500:-4:-401235000
2617#-401234500:-4:-401235000
2618+12345000:4:12340000
2619-12345000:4:-12350000
2620$round_mode('odd')
61f5c3f5 2621+50123456789:5:50123000000
6854fd01 2622-50123456789:5:-50123000000
61f5c3f5 2623+50123456789:9:50123456800
6854fd01 2624-50123456789:9:-50123456800
61f5c3f5 2625+501234500:6:501235000
6854fd01 2626-501234500:6:-501235000
61f5c3f5 2627#+501234500:-4:501235000
6854fd01
JH
2628#-501234500:-4:-501235000
2629+12345000:4:12350000
2630-12345000:4:-12350000
2631$round_mode('even')
61f5c3f5 2632+60123456789:5:60123000000
6854fd01 2633-60123456789:5:-60123000000
61f5c3f5 2634+60123456789:9:60123456800
6854fd01 2635-60123456789:9:-60123456800
61f5c3f5 2636+601234500:6:601234000
6854fd01 2637-601234500:6:-601234000
61f5c3f5 2638#+601234500:-4:601234000
6854fd01
JH
2639#-601234500:-4:-601234000
2640#-601234500:-9:0
2641#-501234500:-9:0
2642#-601234500:-8:0
2643#-501234500:-8:0
2644+1234567:7:1234567
2645+1234567:6:1234570
2646+12345000:4:12340000
2647-12345000:4:-12340000
7b29e1e6
T
2648$round_mode('common')
2649+60123456789:5:60123000000
2650+60123199999:5:60123000000
2651+60123299999:5:60123000000
2652+60123399999:5:60123000000
2653+60123499999:5:60123000000
2654+60123500000:5:60124000000
2655+60123600000:5:60124000000
2656+60123700000:5:60124000000
2657+60123800000:5:60124000000
2658+60123900000:5:60124000000
2659-60123456789:5:-60123000000
2660-60123199999:5:-60123000000
2661-60123299999:5:-60123000000
2662-60123399999:5:-60123000000
2663-60123499999:5:-60123000000
2664-60123500000:5:-60124000000
2665-60123600000:5:-60124000000
2666-60123700000:5:-60124000000
2667-60123800000:5:-60124000000
2668-60123900000:5:-60124000000
6854fd01
JH
2669&is_zero
26700:1
2671NaNzero:0
2672+inf:0
2673-inf:0
2674123:0
2675-1:0
26761:0
2677&is_one
26780:0
2679NaNone:0
2680+inf:0
2681-inf:0
26821:1
26832:0
2684-1:0
2685-2:0
6358232b 2686# floor, ceil, and int are pretty pointless in integer space, but play safe
6854fd01
JH
2687&bfloor
26880:0
2689NaNfloor:NaN
2690+inf:inf
2691-inf:-inf
2692-1:-1
2693-2:-2
26942:2
26953:3
2696abc:NaN
2697&bceil
2698NaNceil:NaN
2699+inf:inf
2700-inf:-inf
27010:0
2702-1:-1
2703-2:-2
27042:2
27053:3
2706abc:NaN
6358232b
PJA
2707&bint
2708NaN:NaN
2709+inf:inf
2710-inf:-inf
27110:0
2712-1:-1
2713-2:-2
27142:2
27153:3
6854fd01
JH
2716&as_hex
2717128:0x80
2718-128:-0x80
27190:0x0
2720-0:0x0
27211:0x1
27220x123456789123456789:0x123456789123456789
2723+inf:inf
2724-inf:-inf
2725NaNas_hex:NaN
2726&as_bin
2727128:0b10000000
2728-128:-0b10000000
27290:0b0
2730-0:0b0
27311:0b1
27320b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101
1ddff52a 27330x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001
6854fd01
JH
2734+inf:inf
2735-inf:-inf
2736NaNas_bin:NaN
06ce15ad
SH
2737# overloaded functions
2738&log
2739-1:NaN
27400:-inf
27411:0
27422:0
27433:1
2744123456789:18
27451234567890987654321:41
2746-inf:inf
2747inf:inf
2748NaN:NaN
2749&exp
2750&sin
2751&cos
2752&atan2
2753&int
2754&neg
2755&abs
2756&sqrt