Commit | Line | Data |
6854fd01 |
1 | #include this file into another for subclass testing |
2 | |
3 | my $version = ${"$class\::VERSION"}; |
4 | |
5 | ############################################################################## |
6 | # for testing inheritance of _swap |
7 | |
8 | package Math::Foo; |
9 | |
61f5c3f5 |
10 | use Math::BigInt lib => $main::CL; |
6854fd01 |
11 | use vars qw/@ISA/; |
12 | @ISA = (qw/Math::BigInt/); |
13 | |
14 | use overload |
15 | # customized overload for sub, since original does not use swap there |
16 | '-' => sub { my @a = ref($_[0])->_swap(@_); |
17 | $a[0]->bsub($a[1])}; |
18 | |
19 | sub _swap |
20 | { |
21 | # a fake _swap, which reverses the params |
22 | my $self = shift; # for override in subclass |
23 | if ($_[2]) |
24 | { |
25 | my $c = ref ($_[0] ) || 'Math::Foo'; |
26 | return ( $_[0]->copy(), $_[1] ); |
27 | } |
28 | else |
29 | { |
30 | return ( Math::Foo->new($_[1]), $_[0] ); |
31 | } |
32 | } |
33 | |
34 | ############################################################################## |
35 | package main; |
36 | |
b3abae2a |
37 | my $CALC = $class->config()->{lib}; ok ($CALC,$CL); |
6854fd01 |
38 | |
b3abae2a |
39 | my ($f,$z,$a,$exp,@a,$m,$e,$round_mode,$expected_class); |
6854fd01 |
40 | |
41 | while (<DATA>) |
42 | { |
d614cd8b |
43 | chomp; |
6854fd01 |
44 | next if /^#/; # skip comments |
45 | if (s/^&//) |
46 | { |
61f5c3f5 |
47 | $f = $_; next; |
6854fd01 |
48 | } |
49 | elsif (/^\$/) |
50 | { |
61f5c3f5 |
51 | $round_mode = $_; $round_mode =~ s/^\$/$class\->/; next; |
6854fd01 |
52 | } |
61f5c3f5 |
53 | |
54 | @args = split(/:/,$_,99); $ans = pop(@args); |
b3abae2a |
55 | $expected_class = $class; |
56 | if ($ans =~ /(.*?)=(.*)/) |
57 | { |
58 | $expected_class = $2; $ans = $1; |
59 | } |
61f5c3f5 |
60 | $try = "\$x = $class->new(\"$args[0]\");"; |
61 | if ($f eq "bnorm") |
6854fd01 |
62 | { |
61f5c3f5 |
63 | $try = "\$x = $class->bnorm(\"$args[0]\");"; |
64 | # some is_xxx tests |
b3abae2a |
65 | } elsif ($f =~ /^is_(zero|one|odd|even|negative|positive|nan|int)$/) { |
61f5c3f5 |
66 | $try .= "\$x->$f();"; |
67 | } elsif ($f eq "as_hex") { |
68 | $try .= '$x->as_hex();'; |
69 | } elsif ($f eq "as_bin") { |
70 | $try .= '$x->as_bin();'; |
71 | } elsif ($f eq "is_inf") { |
72 | $try .= "\$x->is_inf('$args[1]');"; |
73 | } elsif ($f eq "binf") { |
74 | $try .= "\$x->binf('$args[1]');"; |
75 | } elsif ($f eq "bone") { |
76 | $try .= "\$x->bone('$args[1]');"; |
77 | # some unary ops |
b3abae2a |
78 | } elsif ($f =~ /^b(nan|floor|ceil|sstr|neg|abs|inc|dec|not|sqrt|fac)$/) { |
61f5c3f5 |
79 | $try .= "\$x->$f();"; |
80 | } elsif ($f eq "length") { |
81 | $try .= '$x->length();'; |
82 | } elsif ($f eq "exponent"){ |
83 | # ->bstr() to see if an object is returned |
84 | $try .= '$x = $x->exponent()->bstr();'; |
85 | } elsif ($f eq "mantissa"){ |
86 | # ->bstr() to see if an object is returned |
87 | $try .= '$x = $x->mantissa()->bstr();'; |
88 | } elsif ($f eq "parts"){ |
89 | $try .= '($m,$e) = $x->parts();'; |
90 | # ->bstr() to see if an object is returned |
91 | $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;'; |
92 | $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;'; |
93 | $try .= '"$m,$e";'; |
94 | } else { |
95 | $try .= "\$y = $class->new('$args[1]');"; |
96 | if ($f eq "bcmp") |
97 | { |
98 | $try .= '$x <=> $y;'; |
99 | } elsif ($f eq "bround") { |
6854fd01 |
100 | $try .= "$round_mode; \$x->bround(\$y);"; |
61f5c3f5 |
101 | } elsif ($f eq "bacmp"){ |
102 | $try .= '$x->bacmp($y);'; |
103 | } elsif ($f eq "badd"){ |
104 | $try .= '$x + $y;'; |
105 | } elsif ($f eq "bsub"){ |
106 | $try .= '$x - $y;'; |
107 | } elsif ($f eq "bmul"){ |
108 | $try .= '$x * $y;'; |
109 | } elsif ($f eq "bdiv"){ |
110 | $try .= '$x / $y;'; |
111 | } elsif ($f eq "bdiv-list"){ |
112 | $try .= 'join (",",$x->bdiv($y));'; |
027dc388 |
113 | # overload via x= |
61f5c3f5 |
114 | } elsif ($f =~ /^.=$/){ |
115 | $try .= "\$x $f \$y;"; |
027dc388 |
116 | # overload via x |
61f5c3f5 |
117 | } elsif ($f =~ /^.$/){ |
118 | $try .= "\$x $f \$y;"; |
119 | } elsif ($f eq "bmod"){ |
120 | $try .= '$x % $y;'; |
121 | } elsif ($f eq "bgcd") |
6854fd01 |
122 | { |
123 | if (defined $args[2]) |
124 | { |
61f5c3f5 |
125 | $try .= " \$z = $class->new('$args[2]'); "; |
6854fd01 |
126 | } |
127 | $try .= "$class\::bgcd(\$x, \$y"; |
128 | $try .= ", \$z" if (defined $args[2]); |
129 | $try .= " );"; |
130 | } |
131 | elsif ($f eq "blcm") |
132 | { |
133 | if (defined $args[2]) |
134 | { |
61f5c3f5 |
135 | $try .= " \$z = $class->new('$args[2]'); "; |
6854fd01 |
136 | } |
137 | $try .= "$class\::blcm(\$x, \$y"; |
138 | $try .= ", \$z" if (defined $args[2]); |
139 | $try .= " );"; |
140 | }elsif ($f eq "blsft"){ |
141 | if (defined $args[2]) |
142 | { |
143 | $try .= "\$x->blsft(\$y,$args[2]);"; |
144 | } |
145 | else |
146 | { |
147 | $try .= "\$x << \$y;"; |
148 | } |
149 | }elsif ($f eq "brsft"){ |
150 | if (defined $args[2]) |
151 | { |
152 | $try .= "\$x->brsft(\$y,$args[2]);"; |
153 | } |
154 | else |
155 | { |
156 | $try .= "\$x >> \$y;"; |
157 | } |
158 | }elsif ($f eq "band"){ |
159 | $try .= "\$x & \$y;"; |
160 | }elsif ($f eq "bior"){ |
161 | $try .= "\$x | \$y;"; |
162 | }elsif ($f eq "bxor"){ |
163 | $try .= "\$x ^ \$y;"; |
164 | }elsif ($f eq "bpow"){ |
165 | $try .= "\$x ** \$y;"; |
d614cd8b |
166 | } elsif( $f eq "bmodinv") { |
167 | $try .= "\$x->bmodinv(\$y);"; |
6854fd01 |
168 | }elsif ($f eq "digit"){ |
56b9c951 |
169 | $try .= "\$x->digit(\$y);"; |
d614cd8b |
170 | } else { |
171 | $try .= "\$z = $class->new(\"$args[2]\");"; |
172 | |
173 | # Functions with three arguments |
174 | if( $f eq "bmodpow") { |
175 | $try .= "\$x->bmodpow(\$y,\$z);"; |
176 | } else { warn "Unknown op '$f'"; } |
177 | } |
61f5c3f5 |
178 | } # end else all other ops |
179 | |
180 | $ans1 = eval $try; |
181 | # convert hex/binary targets to decimal |
182 | if ($ans =~ /^(0x0x|0b0b)/) |
183 | { |
184 | $ans =~ s/^0[xb]//; $ans = Math::BigInt->new($ans)->bstr(); |
6854fd01 |
185 | } |
61f5c3f5 |
186 | if ($ans eq "") |
187 | { |
188 | ok_undef ($ans1); |
189 | } |
190 | else |
191 | { |
192 | # print "try: $try ans: $ans1 $ans\n"; |
193 | print "# Tried: '$try'\n" if !ok ($ans1, $ans); |
b3abae2a |
194 | ok (ref($ans),$expected_class) if $expected_class ne $class; |
6854fd01 |
195 | } |
61f5c3f5 |
196 | # check internal state of number objects |
197 | is_valid($ans1,$f) if ref $ans1; |
6854fd01 |
198 | } # endwhile data tests |
199 | close DATA; |
200 | |
201 | # test some more |
202 | @a = (); |
203 | for (my $i = 1; $i < 10; $i++) |
204 | { |
205 | push @a, $i; |
206 | } |
207 | ok "@a", "1 2 3 4 5 6 7 8 9"; |
208 | |
209 | # test whether self-multiplication works correctly (result is 2**64) |
210 | $try = "\$x = $class->new('4294967296');"; |
211 | $try .= '$a = $x->bmul($x);'; |
212 | $ans1 = eval $try; |
213 | print "# Tried: '$try'\n" if !ok ($ans1, $class->new(2) ** 64); |
214 | # test self-pow |
215 | $try = "\$x = $class->new(10);"; |
216 | $try .= '$a = $x->bpow($x);'; |
217 | $ans1 = eval $try; |
218 | print "# Tried: '$try'\n" if !ok ($ans1, $class->new(10) ** 10); |
219 | |
07d34614 |
220 | ############################################################################### |
6854fd01 |
221 | # test whether op destroys args or not (should better not) |
222 | |
223 | $x = $class->new(3); |
224 | $y = $class->new(4); |
225 | $z = $x & $y; |
226 | ok ($x,3); |
227 | ok ($y,4); |
228 | ok ($z,0); |
229 | $z = $x | $y; |
230 | ok ($x,3); |
231 | ok ($y,4); |
232 | ok ($z,7); |
233 | $x = $class->new(1); |
234 | $y = $class->new(2); |
235 | $z = $x | $y; |
236 | ok ($x,1); |
237 | ok ($y,2); |
238 | ok ($z,3); |
239 | |
240 | $x = $class->new(5); |
241 | $y = $class->new(4); |
242 | $z = $x ^ $y; |
243 | ok ($x,5); |
244 | ok ($y,4); |
245 | ok ($z,1); |
246 | |
247 | $x = $class->new(-5); $y = -$x; |
248 | ok ($x, -5); |
249 | |
250 | $x = $class->new(-5); $y = abs($x); |
251 | ok ($x, -5); |
252 | |
07d34614 |
253 | $x = $class->new(8); |
254 | $y = $class->new(-1); |
255 | $z = $class->new(5033); |
256 | my $u = $x->copy()->bmodpow($y,$z); |
257 | ok ($u,4404); |
258 | ok ($y,-1); |
259 | ok ($z,5033); |
260 | |
261 | $x = $class->new(-5); $y = -$x; ok ($x,-5); ok ($y,5); |
262 | $x = $class->new(-5); $y = $x->copy()->bneg(); ok ($x,-5); ok ($y,5); |
263 | |
264 | $x = $class->new(-5); $y = $class->new(3); $x->bmul($y); ok ($x,-15); ok ($y,3); |
265 | $x = $class->new(-5); $y = $class->new(3); $x->badd($y); ok ($x,-2); ok ($y,3); |
266 | $x = $class->new(-5); $y = $class->new(3); $x->bsub($y); ok ($x,-8); ok ($y,3); |
267 | $x = $class->new(-15); $y = $class->new(3); $x->bdiv($y); ok ($x,-5); ok ($y,3); |
268 | $x = $class->new(-5); $y = $class->new(3); $x->bmod($y); ok ($x,1); ok ($y,3); |
269 | |
270 | $x = $class->new(5); $y = $class->new(3); $x->bmul($y); ok ($x,15); ok ($y,3); |
271 | $x = $class->new(5); $y = $class->new(3); $x->badd($y); ok ($x,8); ok ($y,3); |
272 | $x = $class->new(5); $y = $class->new(3); $x->bsub($y); ok ($x,2); ok ($y,3); |
273 | $x = $class->new(15); $y = $class->new(3); $x->bdiv($y); ok ($x,5); ok ($y,3); |
274 | $x = $class->new(5); $y = $class->new(3); $x->bmod($y); ok ($x,2); ok ($y,3); |
275 | |
276 | $x = $class->new(5); $y = $class->new(-3); $x->bmul($y); ok ($x,-15); ok($y,-3); |
277 | $x = $class->new(5); $y = $class->new(-3); $x->badd($y); ok ($x,2); ok($y,-3); |
278 | $x = $class->new(5); $y = $class->new(-3); $x->bsub($y); ok ($x,8); ok($y,-3); |
279 | $x = $class->new(15); $y = $class->new(-3); $x->bdiv($y); ok ($x,-5); ok($y,-3); |
280 | $x = $class->new(5); $y = $class->new(-3); $x->bmod($y); ok ($x,-1); ok($y,-3); |
281 | |
282 | ############################################################################### |
6854fd01 |
283 | # check whether overloading cmp works |
284 | $try = "\$x = $class->new(0);"; |
285 | $try .= "\$y = 10;"; |
286 | $try .= "'false' if \$x ne \$y;"; |
287 | $ans = eval $try; |
288 | print "# For '$try'\n" if (!ok "$ans" , "false" ); |
289 | |
290 | # we cant test for working cmpt with other objects here, we would need a dummy |
291 | # object with stringify overload for this. see Math::String tests as example |
292 | |
293 | ############################################################################### |
6854fd01 |
294 | # check reversed order of arguments |
027dc388 |
295 | |
6854fd01 |
296 | $try = "\$x = $class->new(10); \$x = 2 ** \$x;"; |
297 | $try .= "'ok' if \$x == 1024;"; $ans = eval $try; |
298 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
299 | |
300 | $try = "\$x = $class->new(10); \$x = 2 * \$x;"; |
301 | $try .= "'ok' if \$x == 20;"; $ans = eval $try; |
302 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
303 | |
304 | $try = "\$x = $class->new(10); \$x = 2 + \$x;"; |
305 | $try .= "'ok' if \$x == 12;"; $ans = eval $try; |
306 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
307 | |
308 | $try = "\$x = $class\->new(10); \$x = 2 - \$x;"; |
309 | $try .= "'ok' if \$x == -8;"; $ans = eval $try; |
310 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
311 | |
312 | $try = "\$x = $class\->new(10); \$x = 20 / \$x;"; |
313 | $try .= "'ok' if \$x == 2;"; $ans = eval $try; |
314 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
315 | |
027dc388 |
316 | $try = "\$x = $class\->new(3); \$x = 20 % \$x;"; |
317 | $try .= "'ok' if \$x == 2;"; $ans = eval $try; |
318 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
319 | |
320 | $try = "\$x = $class\->new(7); \$x = 20 & \$x;"; |
321 | $try .= "'ok' if \$x == 4;"; $ans = eval $try; |
322 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
323 | |
324 | $try = "\$x = $class\->new(7); \$x = 0x20 | \$x;"; |
325 | $try .= "'ok' if \$x == 0x27;"; $ans = eval $try; |
326 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
327 | |
328 | $try = "\$x = $class\->new(7); \$x = 0x20 ^ \$x;"; |
329 | $try .= "'ok' if \$x == 0x27;"; $ans = eval $try; |
330 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
331 | |
6854fd01 |
332 | ############################################################################### |
333 | # check badd(4,5) form |
334 | |
335 | $try = "\$x = $class\->badd(4,5);"; |
336 | $try .= "'ok' if \$x == 9;"; |
337 | $ans = eval $try; |
338 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
339 | |
340 | ############################################################################### |
341 | # check undefs: NOT DONE YET |
342 | |
343 | ############################################################################### |
344 | # bool |
345 | |
f9a08e12 |
346 | $x = $class->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') } |
347 | $x = $class->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') } |
6854fd01 |
348 | |
349 | ############################################################################### |
350 | # objectify() |
351 | |
352 | @args = Math::BigInt::objectify(2,4,5); |
353 | ok (scalar @args,3); # $class, 4, 5 |
56b9c951 |
354 | ok ($args[0] =~ /^Math::BigInt/); |
6854fd01 |
355 | ok ($args[1],4); |
356 | ok ($args[2],5); |
357 | |
358 | @args = Math::BigInt::objectify(0,4,5); |
359 | ok (scalar @args,3); # $class, 4, 5 |
56b9c951 |
360 | ok ($args[0] =~ /^Math::BigInt/); |
6854fd01 |
361 | ok ($args[1],4); |
362 | ok ($args[2],5); |
363 | |
364 | @args = Math::BigInt::objectify(2,4,5); |
365 | ok (scalar @args,3); # $class, 4, 5 |
56b9c951 |
366 | ok ($args[0] =~ /^Math::BigInt/); |
6854fd01 |
367 | ok ($args[1],4); |
368 | ok ($args[2],5); |
369 | |
370 | @args = Math::BigInt::objectify(2,4,5,6,7); |
371 | ok (scalar @args,5); # $class, 4, 5, 6, 7 |
56b9c951 |
372 | ok ($args[0] =~ /^Math::BigInt/); |
6854fd01 |
373 | ok ($args[1],4); ok (ref($args[1]),$args[0]); |
374 | ok ($args[2],5); ok (ref($args[2]),$args[0]); |
375 | ok ($args[3],6); ok (ref($args[3]),''); |
376 | ok ($args[4],7); ok (ref($args[4]),''); |
377 | |
378 | @args = Math::BigInt::objectify(2,$class,4,5,6,7); |
379 | ok (scalar @args,5); # $class, 4, 5, 6, 7 |
380 | ok ($args[0],$class); |
381 | ok ($args[1],4); ok (ref($args[1]),$args[0]); |
382 | ok ($args[2],5); ok (ref($args[2]),$args[0]); |
383 | ok ($args[3],6); ok (ref($args[3]),''); |
384 | ok ($args[4],7); ok (ref($args[4]),''); |
385 | |
386 | ############################################################################### |
f9a08e12 |
387 | # test whether an opp calls objectify properly or not (or at least does what |
388 | # it should do given non-objects, w/ or w/o objectify()) |
389 | |
390 | ok ($class->new(123)->badd(123),246); |
391 | ok ($class->badd(123,321),444); |
392 | ok ($class->badd(123,$class->new(321)),444); |
393 | |
394 | ok ($class->new(123)->bsub(122),1); |
395 | ok ($class->bsub(321,123),198); |
396 | ok ($class->bsub(321,$class->new(123)),198); |
397 | |
398 | ok ($class->new(123)->bmul(123),15129); |
399 | ok ($class->bmul(123,123),15129); |
400 | ok ($class->bmul(123,$class->new(123)),15129); |
401 | |
402 | ok ($class->new(15129)->bdiv(123),123); |
403 | ok ($class->bdiv(15129,123),123); |
404 | ok ($class->bdiv(15129,$class->new(123)),123); |
405 | |
406 | ok ($class->new(15131)->bmod(123),2); |
407 | ok ($class->bmod(15131,123),2); |
408 | ok ($class->bmod(15131,$class->new(123)),2); |
409 | |
410 | ok ($class->new(2)->bpow(16),65536); |
411 | ok ($class->bpow(2,16),65536); |
412 | ok ($class->bpow(2,$class->new(16)),65536); |
413 | |
414 | ok ($class->new(2**15)->brsft(1),2**14); |
415 | ok ($class->brsft(2**15,1),2**14); |
416 | ok ($class->brsft(2**15,$class->new(1)),2**14); |
417 | |
418 | ok ($class->new(2**13)->blsft(1),2**14); |
419 | ok ($class->blsft(2**13,1),2**14); |
420 | ok ($class->blsft(2**13,$class->new(1)),2**14); |
421 | |
422 | ############################################################################### |
6854fd01 |
423 | # test for floating-point input (other tests in bnorm() below) |
424 | |
425 | $z = 1050000000000000; # may be int on systems with 64bit? |
426 | $x = $class->new($z); ok ($x->bsstr(),'105e+13'); # not 1.05e+15 |
427 | $z = 1e+129; # definitely a float (may fail on UTS) |
428 | # don't compare to $z, since some Perl versions stringify $z into something |
429 | # like '1.e+129' or something equally ugly |
430 | $x = $class->new($z); ok ($x->bsstr(),'1e+129'); |
431 | |
432 | ############################################################################### |
433 | # prime number tests, also test for **= and length() |
434 | # found on: http://www.utm.edu/research/primes/notes/by_year.html |
435 | |
436 | # ((2^148)-1)/17 |
437 | $x = $class->new(2); $x **= 148; $x++; $x = $x / 17; |
438 | ok ($x,"20988936657440586486151264256610222593863921"); |
439 | ok ($x->length(),length "20988936657440586486151264256610222593863921"); |
440 | |
441 | # MM7 = 2^127-1 |
442 | $x = $class->new(2); $x **= 127; $x--; |
443 | ok ($x,"170141183460469231731687303715884105727"); |
444 | |
445 | $x = $class->new('215960156869840440586892398248'); |
446 | ($x,$y) = $x->length(); |
447 | ok ($x,30); ok ($y,0); |
448 | |
449 | $x = $class->new('1_000_000_000_000'); |
450 | ($x,$y) = $x->length(); |
451 | ok ($x,13); ok ($y,0); |
452 | |
453 | # I am afraid the following is not yet possible due to slowness |
454 | # Also, testing for 2 meg output is a bit hard ;) |
455 | #$x = $class->new(2); $x **= 6972593; $x--; |
456 | |
457 | # 593573509*2^332162+1 has exactly 1,000,000 digits |
458 | # takes about 24 mins on 300 Mhz, so cannot be done yet ;) |
459 | #$x = $class->new(2); $x **= 332162; $x *= "593573509"; $x++; |
460 | #ok ($x->length(),1_000_000); |
461 | |
462 | ############################################################################### |
463 | # inheritance and overriding of _swap |
464 | |
465 | $x = Math::Foo->new(5); |
466 | $x = $x - 8; # 8 - 5 instead of 5-8 |
467 | ok ($x,3); |
468 | ok (ref($x),'Math::Foo'); |
469 | |
470 | $x = Math::Foo->new(5); |
471 | $x = 8 - $x; # 5 - 8 instead of 8 - 5 |
472 | ok ($x,-3); |
473 | ok (ref($x),'Math::Foo'); |
474 | |
475 | ############################################################################### |
476 | # Test whether +inf eq inf |
477 | # This tried to test whether BigInt inf equals Perl inf. Unfortunately, Perl |
478 | # hasn't (before 5.7.3 at least) a consistent way to say inf, and some things |
479 | # like 1e100000 crash on some platforms. So simple test for the string 'inf' |
480 | $x = $class->new('+inf'); ok ($x,'inf'); |
481 | |
482 | ############################################################################### |
483 | ############################################################################### |
394e6ffb |
484 | # the followin tests only make sense with Math::BigInt::Calc or BareCalc |
6854fd01 |
485 | |
394e6ffb |
486 | exit if $CALC !~ /^Math::BigInt::(Calc|BareCalc)$/; # for Pari et al. |
6854fd01 |
487 | |
488 | ############################################################################### |
489 | # check proper length of internal arrays |
490 | |
394e6ffb |
491 | my $bl = $CL->_base_len(); |
6854fd01 |
492 | my $BASE = '9' x $bl; |
493 | my $MAX = $BASE; |
494 | $BASE++; |
495 | |
496 | $x = $class->new($MAX); is_valid($x); # f.i. 9999 |
497 | $x += 1; ok ($x,$BASE); is_valid($x); # 10000 |
498 | $x -= 1; ok ($x,$MAX); is_valid($x); # 9999 again |
499 | |
500 | ############################################################################### |
501 | # check numify |
502 | |
503 | $x = $class->new($BASE-1); ok ($x->numify(),$BASE-1); |
504 | $x = $class->new(-($BASE-1)); ok ($x->numify(),-($BASE-1)); |
61f5c3f5 |
505 | |
506 | # +0 is to protect from 1e15 vs 100000000 (stupid to_string aaaarglburblll...) |
507 | $x = $class->new($BASE); ok ($x->numify()+0,$BASE+0); |
6854fd01 |
508 | $x = $class->new(-$BASE); ok ($x->numify(),-$BASE); |
509 | $x = $class->new( -($BASE*$BASE*1+$BASE*1+1) ); |
510 | ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1)); |
511 | |
512 | ############################################################################### |
513 | # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1 |
514 | |
394e6ffb |
515 | $x = $class->new($BASE-2); $x++; $x++; $x++; $x++; |
516 | if ($x > $BASE) { ok (1,1) } else { ok ("$x < $BASE","$x > $BASE"); } |
517 | |
518 | $x = $class->new($BASE+3); $x++; |
519 | if ($x > $BASE) { ok (1,1) } else { ok ("$x > $BASE","$x < $BASE"); } |
6854fd01 |
520 | |
394e6ffb |
521 | # test for +0 instead of int(): |
522 | $x = $class->new($MAX); ok ($x->length(), length($MAX)); |
6854fd01 |
523 | |
524 | ############################################################################### |
56b9c951 |
525 | # test bug that $class->digit($string) did not work |
526 | |
527 | ok ($class->digit(123,2),1); |
528 | |
529 | ############################################################################### |
6854fd01 |
530 | # bug in sub where number with at least 6 trailing zeros after any op failed |
531 | |
394e6ffb |
532 | $x = $class->new(123456); $z = $class->new(10000); $z *= 10; $x -= $z; |
6854fd01 |
533 | ok ($z, 100000); |
534 | ok ($x, 23456); |
535 | |
536 | ############################################################################### |
537 | # bug in shortcut in mul() |
538 | |
61f5c3f5 |
539 | # construct a number with a zero-hole of BASE_LEN_SMALL |
540 | { |
541 | my @bl = $CL->_base_len(); my $bl = $bl[4]; |
542 | |
543 | $x = '1' x $bl . '0' x $bl . '1' x $bl . '0' x $bl; |
544 | $y = '1' x (2*$bl); |
545 | $x = $class->new($x)->bmul($y); |
546 | # result is 123..$bl . $bl x (3*bl-1) . $bl...321 . '0' x $bl |
547 | $y = ''; my $d = ''; |
548 | for (my $i = 1; $i <= $bl; $i++) |
549 | { |
550 | $y .= $i; $d = $i.$d; |
551 | } |
552 | $y .= $bl x (3*$bl-1) . $d . '0' x $bl; |
553 | ok ($x,$y); |
554 | |
6854fd01 |
555 | |
f9a08e12 |
556 | ############################################################################# |
557 | # see if mul shortcut for small numbers works |
394e6ffb |
558 | |
f9a08e12 |
559 | $x = '9' x $bl; |
560 | $x = $class->new($x); |
561 | # 999 * 999 => 998 . 001, 9999*9999 => 9998 . 0001 |
562 | ok ($x*$x, '9' x ($bl-1) . '8' . '0' x ($bl-1) . '1'); |
563 | } |
61f5c3f5 |
564 | |
394e6ffb |
565 | ############################################################################### |
6854fd01 |
566 | # bug with rest "-0" in div, causing further div()s to fail |
567 | |
394e6ffb |
568 | $x = $class->new('-322056000'); ($x,$y) = $x->bdiv('-12882240'); |
6854fd01 |
569 | |
61f5c3f5 |
570 | ok ($y,'0'); is_valid($y); # $y not '-0' |
394e6ffb |
571 | |
79c55733 |
572 | ############################################################################### |
f9a08e12 |
573 | # bug in $x->bmod($y) |
07d34614 |
574 | |
f9a08e12 |
575 | # if $x < 0 and $y > 0 |
07d34614 |
576 | $x = $class->new('-629'); ok ($x->bmod(5033),4404); |
577 | |
578 | ############################################################################### |
56b9c951 |
579 | # bone/binf etc as plain calls (Lite failed them) |
580 | |
581 | ok ($class->bzero(),0); |
582 | ok ($class->bone(),1); |
583 | ok ($class->bone('+'),1); |
584 | ok ($class->bone('-'),-1); |
585 | ok ($class->bnan(),'NaN'); |
586 | ok ($class->binf(),'inf'); |
587 | ok ($class->binf('+'),'inf'); |
588 | ok ($class->binf('-'),'-inf'); |
589 | ok ($class->binf('-inf'),'-inf'); |
590 | |
591 | ############################################################################### |
61f5c3f5 |
592 | # all tests done |
6854fd01 |
593 | |
594 | 1; |
595 | |
596 | ############################################################################### |
61f5c3f5 |
597 | ############################################################################### |
6854fd01 |
598 | # Perl 5.005 does not like ok ($x,undef) |
599 | |
600 | sub ok_undef |
601 | { |
602 | my $x = shift; |
603 | |
604 | ok (1,1) and return if !defined $x; |
605 | ok ($x,'undef'); |
606 | } |
607 | |
608 | ############################################################################### |
609 | # sub to check validity of a BigInt internally, to ensure that no op leaves a |
610 | # number object in an invalid state (f.i. "-0") |
611 | |
612 | sub is_valid |
613 | { |
614 | my ($x,$f) = @_; |
615 | |
616 | my $e = 0; # error? |
6854fd01 |
617 | |
56b9c951 |
618 | # allow the check to pass for all Lite, and all MBI and subclasses |
619 | # ok as reference? |
620 | $e = 'Not a reference to Math::BigInt' if ref($x) !~ /^Math::BigInt/; |
6854fd01 |
621 | |
56b9c951 |
622 | if (ref($x) ne 'Math::BigInt::Lite') |
623 | { |
624 | # has ok sign? |
625 | $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'" |
626 | if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/; |
627 | |
628 | $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0; |
629 | $e = $CALC->_check($x->{value}) if $e eq '0'; |
630 | } |
6854fd01 |
631 | |
632 | # test done, see if error did crop up |
633 | ok (1,1), return if ($e eq '0'); |
634 | |
027dc388 |
635 | ok (1,$e." after op '$f'"); |
6854fd01 |
636 | } |
637 | |
638 | __DATA__ |
027dc388 |
639 | &.= |
640 | 1234:-345:1234-345 |
641 | &+= |
642 | 1:2:3 |
643 | -1:-2:-3 |
644 | &-= |
645 | 1:2:-1 |
646 | -1:-2:1 |
647 | &*= |
648 | 2:3:6 |
649 | -1:5:-5 |
650 | &%= |
651 | 100:3:1 |
652 | 8:9:8 |
07d34614 |
653 | -629:5033:4404 |
027dc388 |
654 | &/= |
655 | 100:3:33 |
656 | -8:2:-4 |
657 | &|= |
658 | 2:1:3 |
659 | &&= |
660 | 5:7:5 |
661 | &^= |
662 | 5:7:2 |
6854fd01 |
663 | &is_negative |
664 | 0:0 |
665 | -1:1 |
666 | 1:0 |
667 | +inf:0 |
668 | -inf:1 |
669 | NaNneg:0 |
670 | &is_positive |
671 | 0:1 |
672 | -1:0 |
673 | 1:1 |
674 | +inf:1 |
675 | -inf:0 |
676 | NaNneg:0 |
b3abae2a |
677 | &is_int |
678 | -inf:0 |
679 | +inf:0 |
680 | NaNis_int:0 |
681 | 1:1 |
682 | 0:1 |
683 | 123e12:1 |
6854fd01 |
684 | &is_odd |
685 | abc:0 |
686 | 0:0 |
687 | 1:1 |
688 | 3:1 |
689 | -1:1 |
690 | -3:1 |
691 | 10000001:1 |
692 | 10000002:0 |
693 | 2:0 |
b3abae2a |
694 | 120:0 |
695 | 121:1 |
6854fd01 |
696 | &is_even |
697 | abc:0 |
698 | 0:1 |
699 | 1:0 |
700 | 3:0 |
701 | -1:0 |
702 | -3:0 |
703 | 10000001:0 |
704 | 10000002:1 |
705 | 2:1 |
b3abae2a |
706 | 120:1 |
707 | 121:0 |
6854fd01 |
708 | &bacmp |
709 | +0:-0:0 |
710 | +0:+1:-1 |
711 | -1:+1:0 |
712 | +1:-1:0 |
713 | -1:+2:-1 |
714 | +2:-1:1 |
715 | -123456789:+987654321:-1 |
716 | +123456789:-987654321:-1 |
717 | +987654321:+123456789:1 |
718 | -987654321:+123456789:1 |
719 | -123:+4567889:-1 |
720 | # NaNs |
721 | acmpNaN:123: |
722 | 123:acmpNaN: |
723 | acmpNaN:acmpNaN: |
724 | # infinity |
725 | +inf:+inf:0 |
726 | -inf:-inf:0 |
727 | +inf:-inf:0 |
728 | -inf:+inf:0 |
729 | +inf:123:1 |
730 | -inf:123:1 |
731 | +inf:-123:1 |
732 | -inf:-123:1 |
733 | # return undef |
734 | +inf:NaN: |
735 | NaN:inf: |
736 | -inf:NaN: |
737 | NaN:-inf: |
738 | &bnorm |
739 | 123:123 |
740 | # binary input |
741 | 0babc:NaN |
742 | 0b123:NaN |
743 | 0b0:0 |
744 | -0b0:0 |
745 | -0b1:-1 |
746 | 0b0001:1 |
747 | 0b001:1 |
748 | 0b011:3 |
749 | 0b101:5 |
61f5c3f5 |
750 | 0b1001:9 |
751 | 0b10001:17 |
752 | 0b100001:33 |
753 | 0b1000001:65 |
754 | 0b10000001:129 |
755 | 0b100000001:257 |
756 | 0b1000000001:513 |
757 | 0b10000000001:1025 |
758 | 0b100000000001:2049 |
759 | 0b1000000000001:4097 |
760 | 0b10000000000001:8193 |
761 | 0b100000000000001:16385 |
762 | 0b1000000000000001:32769 |
763 | 0b10000000000000001:65537 |
764 | 0b100000000000000001:131073 |
765 | 0b1000000000000000001:262145 |
766 | 0b10000000000000000001:524289 |
767 | 0b100000000000000000001:1048577 |
768 | 0b1000000000000000000001:2097153 |
769 | 0b10000000000000000000001:4194305 |
770 | 0b100000000000000000000001:8388609 |
771 | 0b1000000000000000000000001:16777217 |
772 | 0b10000000000000000000000001:33554433 |
773 | 0b100000000000000000000000001:67108865 |
774 | 0b1000000000000000000000000001:134217729 |
775 | 0b10000000000000000000000000001:268435457 |
776 | 0b100000000000000000000000000001:536870913 |
777 | 0b1000000000000000000000000000001:1073741825 |
778 | 0b10000000000000000000000000000001:2147483649 |
779 | 0b100000000000000000000000000000001:4294967297 |
780 | 0b1000000000000000000000000000000001:8589934593 |
781 | 0b10000000000000000000000000000000001:17179869185 |
6854fd01 |
782 | 0b_101:NaN |
783 | 0b1_0_1:5 |
394e6ffb |
784 | 0b0_0_0_1:1 |
6854fd01 |
785 | # hex input |
786 | -0x0:0 |
787 | 0xabcdefgh:NaN |
788 | 0x1234:4660 |
789 | 0xabcdef:11259375 |
790 | -0xABCDEF:-11259375 |
791 | -0x1234:-4660 |
792 | 0x12345678:305419896 |
793 | 0x1_2_3_4_56_78:305419896 |
394e6ffb |
794 | 0xa_b_c_d_e_f:11259375 |
6854fd01 |
795 | 0x_123:NaN |
61f5c3f5 |
796 | 0x9:9 |
797 | 0x11:17 |
798 | 0x21:33 |
799 | 0x41:65 |
800 | 0x81:129 |
801 | 0x101:257 |
802 | 0x201:513 |
803 | 0x401:1025 |
804 | 0x801:2049 |
805 | 0x1001:4097 |
806 | 0x2001:8193 |
807 | 0x4001:16385 |
808 | 0x8001:32769 |
809 | 0x10001:65537 |
810 | 0x20001:131073 |
811 | 0x40001:262145 |
812 | 0x80001:524289 |
813 | 0x100001:1048577 |
814 | 0x200001:2097153 |
815 | 0x400001:4194305 |
816 | 0x800001:8388609 |
817 | 0x1000001:16777217 |
818 | 0x2000001:33554433 |
819 | 0x4000001:67108865 |
820 | 0x8000001:134217729 |
821 | 0x10000001:268435457 |
822 | 0x20000001:536870913 |
823 | 0x40000001:1073741825 |
824 | 0x80000001:2147483649 |
825 | 0x100000001:4294967297 |
826 | 0x200000001:8589934593 |
827 | 0x400000001:17179869185 |
828 | 0x800000001:34359738369 |
6854fd01 |
829 | # inf input |
830 | inf:inf |
831 | +inf:inf |
832 | -inf:-inf |
833 | 0inf:NaN |
027dc388 |
834 | # abnormal input |
6854fd01 |
835 | :NaN |
836 | abc:NaN |
837 | 1 a:NaN |
838 | 1bcd2:NaN |
839 | 11111b:NaN |
840 | +1z:NaN |
841 | -1z:NaN |
027dc388 |
842 | # only one underscore between two digits |
843 | _123:NaN |
844 | _123_:NaN |
845 | 123_:NaN |
846 | 1__23:NaN |
847 | 1E1__2:NaN |
848 | 1_E12:NaN |
849 | 1E_12:NaN |
850 | 1_E_12:NaN |
851 | +_1E12:NaN |
852 | +0_1E2:100 |
853 | +0_0_1E2:100 |
854 | -0_0_1E2:-100 |
855 | -0_0_1E+0_0_2:-100 |
856 | E1:NaN |
857 | E23:NaN |
858 | 1.23E1:NaN |
859 | 1.23E-1:NaN |
860 | # bug with two E's in number beeing valid |
861 | 1e2e3:NaN |
862 | 1e2r:NaN |
863 | 1e2.0:NaN |
07d34614 |
864 | # bug with two '.' in number beeing valid |
865 | 1.2.2:NaN |
866 | 1.2.3e1:NaN |
867 | -1.2.3:NaN |
868 | -1.2.3e-4:NaN |
869 | 1.2e3.4:NaN |
870 | 1.2e-3.4:NaN |
871 | 1.2.3.4:NaN |
872 | 1.2.t:NaN |
873 | 1..2:NaN |
874 | 1..2e1:NaN |
875 | 1..2e1..1:NaN |
876 | 12e1..1:NaN |
877 | ..2:NaN |
878 | .-2:NaN |
61f5c3f5 |
879 | # leading zeros |
880 | 012:12 |
881 | 0123:123 |
882 | 01234:1234 |
883 | 012345:12345 |
884 | 0123456:123456 |
885 | 01234567:1234567 |
886 | 012345678:12345678 |
887 | 0123456789:123456789 |
888 | 01234567891:1234567891 |
889 | 012345678912:12345678912 |
890 | 0123456789123:123456789123 |
891 | 01234567891234:1234567891234 |
027dc388 |
892 | # normal input |
6854fd01 |
893 | 0:0 |
894 | +0:0 |
895 | +00:0 |
896 | +000:0 |
897 | 000000000000000000:0 |
898 | -0:0 |
899 | -0000:0 |
900 | +1:1 |
901 | +01:1 |
902 | +001:1 |
903 | +00000100000:100000 |
904 | 123456789:123456789 |
905 | -1:-1 |
906 | -01:-1 |
907 | -001:-1 |
908 | -123456789:-123456789 |
909 | -00000100000:-100000 |
910 | 1_2_3:123 |
6854fd01 |
911 | 10000000000E-1_0:1 |
912 | 1E2:100 |
913 | 1E1:10 |
914 | 1E0:1 |
6854fd01 |
915 | 1.23E2:123 |
6854fd01 |
916 | 100E-1:10 |
917 | # floating point input |
027dc388 |
918 | # .2e2:20 |
919 | 1.E3:1000 |
6854fd01 |
920 | 1.01E2:101 |
921 | 1010E-1:101 |
922 | -1010E0:-1010 |
923 | -1010E1:-10100 |
027dc388 |
924 | 1234.00:1234 |
925 | # non-integer numbers |
6854fd01 |
926 | -1010E-2:NaN |
927 | -1.01E+1:NaN |
928 | -1.01E-1:NaN |
6854fd01 |
929 | &bnan |
930 | 1:NaN |
931 | 2:NaN |
932 | abc:NaN |
933 | &bone |
61f5c3f5 |
934 | 2:+:1 |
6854fd01 |
935 | 2:-:-1 |
936 | boneNaN:-:-1 |
61f5c3f5 |
937 | boneNaN:+:1 |
938 | 2:abc:1 |
939 | 3::1 |
6854fd01 |
940 | &binf |
941 | 1:+:inf |
942 | 2:-:-inf |
943 | 3:abc:inf |
027dc388 |
944 | &is_nan |
945 | 123:0 |
946 | abc:1 |
947 | NaN:1 |
948 | -123:0 |
6854fd01 |
949 | &is_inf |
950 | +inf::1 |
951 | -inf::1 |
952 | abc::0 |
953 | 1::0 |
954 | NaN::0 |
955 | -1::0 |
956 | +inf:-:0 |
957 | +inf:+:1 |
958 | -inf:-:1 |
959 | -inf:+:0 |
79c55733 |
960 | -inf:-inf:1 |
961 | -inf:+inf:0 |
962 | +inf:-inf:0 |
963 | +inf:+inf:1 |
6854fd01 |
964 | # it must be exactly /^[+-]inf$/ |
965 | +infinity::0 |
966 | -infinity::0 |
967 | &blsft |
968 | abc:abc:NaN |
61f5c3f5 |
969 | +2:+2:8 |
970 | +1:+32:4294967296 |
971 | +1:+48:281474976710656 |
6854fd01 |
972 | +8:-2:NaN |
973 | # excercise base 10 |
974 | +12345:4:10:123450000 |
975 | -1234:0:10:-1234 |
61f5c3f5 |
976 | +1234:0:10:1234 |
6854fd01 |
977 | +2:2:10:200 |
978 | +12:2:10:1200 |
979 | +1234:-3:10:NaN |
980 | 1234567890123:12:10:1234567890123000000000000 |
b3abae2a |
981 | -3:1:2:-6 |
982 | -5:1:2:-10 |
983 | -2:1:2:-4 |
984 | -102533203:1:2:-205066406 |
6854fd01 |
985 | &brsft |
986 | abc:abc:NaN |
61f5c3f5 |
987 | +8:+2:2 |
988 | +4294967296:+32:1 |
989 | +281474976710656:+48:1 |
6854fd01 |
990 | +2:-2:NaN |
991 | # excercise base 10 |
992 | -1234:0:10:-1234 |
61f5c3f5 |
993 | +1234:0:10:1234 |
6854fd01 |
994 | +200:2:10:2 |
995 | +1234:3:10:1 |
996 | +1234:2:10:12 |
997 | +1234:-3:10:NaN |
998 | 310000:4:10:31 |
999 | 12300000:5:10:123 |
1000 | 1230000000000:10:10:123 |
1001 | 09876123456789067890:12:10:9876123 |
1002 | 1234561234567890123:13:10:123456 |
b3abae2a |
1003 | 820265627:1:2:410132813 |
1004 | # test shifting negative numbers in base 2 |
1005 | -15:1:2:-8 |
1006 | -14:1:2:-7 |
1007 | -13:1:2:-7 |
1008 | -12:1:2:-6 |
1009 | -11:1:2:-6 |
1010 | -10:1:2:-5 |
1011 | -9:1:2:-5 |
1012 | -8:1:2:-4 |
1013 | -7:1:2:-4 |
1014 | -6:1:2:-3 |
1015 | -5:1:2:-3 |
1016 | -4:1:2:-2 |
1017 | -3:1:2:-2 |
1018 | -2:1:2:-1 |
1019 | -1:1:2:-1 |
1020 | -1640531254:2:2:-410132814 |
1021 | -1640531254:1:2:-820265627 |
1022 | -820265627:1:2:-410132814 |
1023 | -205066405:1:2:-102533203 |
6854fd01 |
1024 | &bsstr |
1025 | 1e+34:1e+34 |
1026 | 123.456E3:123456e+0 |
1027 | 100:1e+2 |
1028 | abc:NaN |
1029 | &bneg |
1030 | bnegNaN:NaN |
1031 | +inf:-inf |
1032 | -inf:inf |
1033 | abd:NaN |
61f5c3f5 |
1034 | 0:0 |
1035 | 1:-1 |
1036 | -1:1 |
6854fd01 |
1037 | +123456789:-123456789 |
61f5c3f5 |
1038 | -123456789:123456789 |
6854fd01 |
1039 | &babs |
1040 | babsNaN:NaN |
1041 | +inf:inf |
1042 | -inf:inf |
61f5c3f5 |
1043 | 0:0 |
1044 | 1:1 |
1045 | -1:1 |
1046 | +123456789:123456789 |
1047 | -123456789:123456789 |
6854fd01 |
1048 | &bcmp |
1049 | bcmpNaN:bcmpNaN: |
61f5c3f5 |
1050 | bcmpNaN:0: |
1051 | 0:bcmpNaN: |
1052 | 0:0:0 |
1053 | -1:0:-1 |
1054 | 0:-1:1 |
1055 | 1:0:1 |
1056 | 0:1:-1 |
1057 | -1:1:-1 |
1058 | 1:-1:1 |
6854fd01 |
1059 | -1:-1:0 |
61f5c3f5 |
1060 | 1:1:0 |
1061 | 123:123:0 |
1062 | 123:12:1 |
1063 | 12:123:-1 |
6854fd01 |
1064 | -123:-123:0 |
1065 | -123:-12:-1 |
1066 | -12:-123:1 |
61f5c3f5 |
1067 | 123:124:-1 |
1068 | 124:123:1 |
6854fd01 |
1069 | -123:-124:1 |
1070 | -124:-123:-1 |
61f5c3f5 |
1071 | 100:5:1 |
1072 | -123456789:987654321:-1 |
6854fd01 |
1073 | +123456789:-987654321:1 |
61f5c3f5 |
1074 | -987654321:123456789:-1 |
6854fd01 |
1075 | -inf:5432112345:-1 |
1076 | +inf:5432112345:1 |
1077 | -inf:-5432112345:-1 |
1078 | +inf:-5432112345:1 |
1079 | +inf:+inf:0 |
1080 | -inf:-inf:0 |
1081 | +inf:-inf:1 |
1082 | -inf:+inf:-1 |
1083 | 5:inf:-1 |
1084 | 5:inf:-1 |
1085 | -5:-inf:1 |
1086 | -5:-inf:1 |
1087 | # return undef |
1088 | +inf:NaN: |
1089 | NaN:inf: |
1090 | -inf:NaN: |
1091 | NaN:-inf: |
1092 | &binc |
1093 | abc:NaN |
1094 | +inf:inf |
1095 | -inf:-inf |
61f5c3f5 |
1096 | +0:1 |
1097 | +1:2 |
1098 | -1:0 |
6854fd01 |
1099 | &bdec |
1100 | abc:NaN |
1101 | +inf:inf |
1102 | -inf:-inf |
1103 | +0:-1 |
61f5c3f5 |
1104 | +1:0 |
6854fd01 |
1105 | -1:-2 |
1106 | &badd |
1107 | abc:abc:NaN |
61f5c3f5 |
1108 | abc:0:NaN |
6854fd01 |
1109 | +0:abc:NaN |
b3abae2a |
1110 | +inf:-inf:NaN |
1111 | -inf:+inf:NaN |
6854fd01 |
1112 | +inf:+inf:inf |
1113 | -inf:-inf:-inf |
1114 | baddNaN:+inf:NaN |
1115 | baddNaN:+inf:NaN |
1116 | +inf:baddNaN:NaN |
1117 | -inf:baddNaN:NaN |
61f5c3f5 |
1118 | 0:0:0 |
1119 | 1:0:1 |
1120 | 0:1:1 |
1121 | 1:1:2 |
1122 | -1:0:-1 |
1123 | 0:-1:-1 |
6854fd01 |
1124 | -1:-1:-2 |
61f5c3f5 |
1125 | -1:+1:0 |
1126 | +1:-1:0 |
1127 | +9:+1:10 |
1128 | +99:+1:100 |
1129 | +999:+1:1000 |
1130 | +9999:+1:10000 |
1131 | +99999:+1:100000 |
1132 | +999999:+1:1000000 |
1133 | +9999999:+1:10000000 |
1134 | +99999999:+1:100000000 |
1135 | +999999999:+1:1000000000 |
1136 | +9999999999:+1:10000000000 |
1137 | +99999999999:+1:100000000000 |
1138 | +10:-1:9 |
1139 | +100:-1:99 |
1140 | +1000:-1:999 |
1141 | +10000:-1:9999 |
1142 | +100000:-1:99999 |
1143 | +1000000:-1:999999 |
1144 | +10000000:-1:9999999 |
1145 | +100000000:-1:99999999 |
1146 | +1000000000:-1:999999999 |
1147 | +10000000000:-1:9999999999 |
1148 | +123456789:987654321:1111111110 |
1149 | -123456789:987654321:864197532 |
6854fd01 |
1150 | -123456789:-987654321:-1111111110 |
1151 | +123456789:-987654321:-864197532 |
56b9c951 |
1152 | -1:10001:10000 |
1153 | -1:100001:100000 |
1154 | -1:1000001:1000000 |
1155 | -1:10000001:10000000 |
1156 | -1:100000001:100000000 |
1157 | -1:1000000001:1000000000 |
1158 | -1:10000000001:10000000000 |
1159 | -1:100000000001:100000000000 |
1160 | -1:1000000000001:1000000000000 |
1161 | -1:10000000000001:10000000000000 |
1162 | -1:-10001:-10002 |
1163 | -1:-100001:-100002 |
1164 | -1:-1000001:-1000002 |
1165 | -1:-10000001:-10000002 |
1166 | -1:-100000001:-100000002 |
1167 | -1:-1000000001:-1000000002 |
1168 | -1:-10000000001:-10000000002 |
1169 | -1:-100000000001:-100000000002 |
1170 | -1:-1000000000001:-1000000000002 |
1171 | -1:-10000000000001:-10000000000002 |
6854fd01 |
1172 | &bsub |
1173 | abc:abc:NaN |
1174 | abc:+0:NaN |
1175 | +0:abc:NaN |
1176 | +inf:-inf:inf |
1177 | -inf:+inf:-inf |
b3abae2a |
1178 | +inf:+inf:NaN |
1179 | -inf:-inf:NaN |
61f5c3f5 |
1180 | +0:+0:0 |
1181 | +1:+0:1 |
6854fd01 |
1182 | +0:+1:-1 |
61f5c3f5 |
1183 | +1:+1:0 |
6854fd01 |
1184 | -1:+0:-1 |
61f5c3f5 |
1185 | +0:-1:1 |
1186 | -1:-1:0 |
6854fd01 |
1187 | -1:+1:-2 |
61f5c3f5 |
1188 | +1:-1:2 |
1189 | +9:+1:8 |
1190 | +99:+1:98 |
1191 | +999:+1:998 |
1192 | +9999:+1:9998 |
1193 | +99999:+1:99998 |
1194 | +999999:+1:999998 |
1195 | +9999999:+1:9999998 |
1196 | +99999999:+1:99999998 |
1197 | +999999999:+1:999999998 |
1198 | +9999999999:+1:9999999998 |
1199 | +99999999999:+1:99999999998 |
1200 | +10:-1:11 |
1201 | +100:-1:101 |
1202 | +1000:-1:1001 |
1203 | +10000:-1:10001 |
1204 | +100000:-1:100001 |
1205 | +1000000:-1:1000001 |
1206 | +10000000:-1:10000001 |
1207 | +100000000:-1:100000001 |
1208 | +1000000000:-1:1000000001 |
1209 | +10000000000:-1:10000000001 |
6854fd01 |
1210 | +123456789:+987654321:-864197532 |
1211 | -123456789:+987654321:-1111111110 |
61f5c3f5 |
1212 | -123456789:-987654321:864197532 |
1213 | +123456789:-987654321:1111111110 |
56b9c951 |
1214 | 10001:1:10000 |
1215 | 100001:1:100000 |
1216 | 1000001:1:1000000 |
1217 | 10000001:1:10000000 |
1218 | 100000001:1:100000000 |
1219 | 1000000001:1:1000000000 |
1220 | 10000000001:1:10000000000 |
1221 | 100000000001:1:100000000000 |
1222 | 1000000000001:1:1000000000000 |
1223 | 10000000000001:1:10000000000000 |
1224 | 10001:-1:10002 |
1225 | 100001:-1:100002 |
1226 | 1000001:-1:1000002 |
1227 | 10000001:-1:10000002 |
1228 | 100000001:-1:100000002 |
1229 | 1000000001:-1:1000000002 |
1230 | 10000000001:-1:10000000002 |
1231 | 100000000001:-1:100000000002 |
1232 | 1000000000001:-1:1000000000002 |
1233 | 10000000000001:-1:10000000000002 |
6854fd01 |
1234 | &bmul |
1235 | abc:abc:NaN |
1236 | abc:+0:NaN |
1237 | +0:abc:NaN |
1238 | NaNmul:+inf:NaN |
1239 | NaNmul:-inf:NaN |
1240 | -inf:NaNmul:NaN |
1241 | +inf:NaNmul:NaN |
1242 | +inf:+inf:inf |
1243 | +inf:-inf:-inf |
1244 | -inf:+inf:-inf |
1245 | -inf:-inf:inf |
61f5c3f5 |
1246 | +0:+0:0 |
1247 | +0:+1:0 |
1248 | +1:+0:0 |
1249 | +0:-1:0 |
1250 | -1:+0:0 |
1251 | 123456789123456789:0:0 |
1252 | 0:123456789123456789:0 |
1253 | -1:-1:1 |
6854fd01 |
1254 | -1:+1:-1 |
1255 | +1:-1:-1 |
61f5c3f5 |
1256 | +1:+1:1 |
1257 | +2:+3:6 |
6854fd01 |
1258 | -2:+3:-6 |
1259 | +2:-3:-6 |
61f5c3f5 |
1260 | -2:-3:6 |
1261 | 111:111:12321 |
1262 | 10101:10101:102030201 |
1263 | 1001001:1001001:1002003002001 |
1264 | 100010001:100010001:10002000300020001 |
1265 | 10000100001:10000100001:100002000030000200001 |
1266 | 11111111111:9:99999999999 |
1267 | 22222222222:9:199999999998 |
1268 | 33333333333:9:299999999997 |
1269 | 44444444444:9:399999999996 |
1270 | 55555555555:9:499999999995 |
1271 | 66666666666:9:599999999994 |
1272 | 77777777777:9:699999999993 |
1273 | 88888888888:9:799999999992 |
1274 | 99999999999:9:899999999991 |
1275 | +25:+25:625 |
1276 | +12345:+12345:152399025 |
1277 | +99999:+11111:1111088889 |
6854fd01 |
1278 | 9999:10000:99990000 |
1279 | 99999:100000:9999900000 |
1280 | 999999:1000000:999999000000 |
1281 | 9999999:10000000:99999990000000 |
1282 | 99999999:100000000:9999999900000000 |
1283 | 999999999:1000000000:999999999000000000 |
1284 | 9999999999:10000000000:99999999990000000000 |
1285 | 99999999999:100000000000:9999999999900000000000 |
1286 | 999999999999:1000000000000:999999999999000000000000 |
1287 | 9999999999999:10000000000000:99999999999990000000000000 |
1288 | 99999999999999:100000000000000:9999999999999900000000000000 |
1289 | 999999999999999:1000000000000000:999999999999999000000000000000 |
1290 | 9999999999999999:10000000000000000:99999999999999990000000000000000 |
1291 | 99999999999999999:100000000000000000:9999999999999999900000000000000000 |
1292 | 999999999999999999:1000000000000000000:999999999999999999000000000000000000 |
1293 | 9999999999999999999:10000000000000000000:99999999999999999990000000000000000000 |
1294 | &bdiv-list |
1295 | 100:20:5,0 |
1296 | 4095:4095:1,0 |
1297 | -4095:-4095:1,0 |
1298 | 4095:-4095:-1,0 |
1299 | -4095:4095:-1,0 |
1300 | 123:2:61,1 |
b3abae2a |
1301 | 9:5:1,4 |
1302 | 9:4:2,1 |
6854fd01 |
1303 | # inf handling and general remainder |
1304 | 5:8:0,5 |
1305 | 0:8:0,0 |
1306 | 11:2:5,1 |
1307 | 11:-2:-5,-1 |
1308 | -11:2:-5,1 |
1309 | # see table in documentation in MBI |
1310 | 0:inf:0,0 |
1311 | 0:-inf:0,0 |
1312 | 5:inf:0,5 |
1313 | 5:-inf:0,5 |
1314 | -5:inf:0,-5 |
1315 | -5:-inf:0,-5 |
1316 | inf:5:inf,0 |
1317 | -inf:5:-inf,0 |
1318 | inf:-5:-inf,0 |
1319 | -inf:-5:inf,0 |
1320 | 5:5:1,0 |
1321 | -5:-5:1,0 |
b3abae2a |
1322 | inf:inf:NaN,NaN |
1323 | -inf:-inf:NaN,NaN |
1324 | -inf:inf:NaN,NaN |
1325 | inf:-inf:NaN,NaN |
6854fd01 |
1326 | 8:0:inf,8 |
1327 | inf:0:inf,inf |
1328 | # exceptions to reminder rule |
1329 | -8:0:-inf,-8 |
1330 | -inf:0:-inf,-inf |
1331 | 0:0:NaN,NaN |
1332 | &bdiv |
1333 | abc:abc:NaN |
61f5c3f5 |
1334 | abc:1:NaN |
1335 | 1:abc:NaN |
1336 | 0:0:NaN |
6854fd01 |
1337 | # inf handling (see table in doc) |
1338 | 0:inf:0 |
1339 | 0:-inf:0 |
1340 | 5:inf:0 |
1341 | 5:-inf:0 |
1342 | -5:inf:0 |
1343 | -5:-inf:0 |
1344 | inf:5:inf |
1345 | -inf:5:-inf |
1346 | inf:-5:-inf |
1347 | -inf:-5:inf |
1348 | 5:5:1 |
1349 | -5:-5:1 |
b3abae2a |
1350 | inf:inf:NaN |
1351 | -inf:-inf:NaN |
1352 | -inf:inf:NaN |
1353 | inf:-inf:NaN |
6854fd01 |
1354 | 8:0:inf |
1355 | inf:0:inf |
1356 | -8:0:-inf |
1357 | -inf:0:-inf |
1358 | 0:0:NaN |
1359 | 11:2:5 |
1360 | -11:-2:5 |
1361 | -11:2:-5 |
1362 | 11:-2:-5 |
61f5c3f5 |
1363 | 0:1:0 |
1364 | 0:-1:0 |
1365 | 1:1:1 |
1366 | -1:-1:1 |
1367 | 1:-1:-1 |
1368 | -1:1:-1 |
1369 | 1:2:0 |
1370 | 2:1:2 |
1371 | 1:26:0 |
1372 | 1000000000:9:111111111 |
1373 | 2000000000:9:222222222 |
1374 | 3000000000:9:333333333 |
1375 | 4000000000:9:444444444 |
1376 | 5000000000:9:555555555 |
1377 | 6000000000:9:666666666 |
1378 | 7000000000:9:777777777 |
1379 | 8000000000:9:888888888 |
1380 | 9000000000:9:1000000000 |
1381 | 35500000:113:314159 |
1382 | 71000000:226:314159 |
1383 | 106500000:339:314159 |
1384 | 1000000000:3:333333333 |
1385 | +10:+5:2 |
1386 | +100:+4:25 |
1387 | +1000:+8:125 |
1388 | +10000:+16:625 |
1389 | 999999999999:9:111111111111 |
1390 | 999999999999:99:10101010101 |
1391 | 999999999999:999:1001001001 |
1392 | 999999999999:9999:100010001 |
1393 | 999999999999999:99999:10000100001 |
1394 | +1111088889:99999:11111 |
6854fd01 |
1395 | -5:-3:1 |
1396 | -5:3:-1 |
1397 | 4:3:1 |
1398 | 4:-3:-1 |
1399 | 1:3:0 |
1400 | 1:-3:0 |
1401 | -2:-3:0 |
1402 | -2:3:0 |
1403 | 8:3:2 |
1404 | -8:3:-2 |
1405 | 14:-3:-4 |
1406 | -14:3:-4 |
1407 | -14:-3:4 |
1408 | 14:3:4 |
1409 | # bug in Calc with '99999' vs $BASE-1 |
1410 | 10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576 |
07d34614 |
1411 | &bmodinv |
1412 | # format: number:modulus:result |
1413 | # bmodinv Data errors |
1414 | abc:abc:NaN |
1415 | abc:5:NaN |
1416 | 5:abc:NaN |
1417 | # bmodinv Expected Results from normal use |
1418 | 1:5:1 |
1419 | 3:5:2 |
1420 | -2:5:2 |
1421 | 8:5033:4404 |
1422 | 324958749843759385732954874325984357439658735983745:2348249874968739:1741662881064902 |
d614cd8b |
1423 | ## bmodinv Error cases / useless use of function |
07d34614 |
1424 | 3:-5:NaN |
1425 | inf:5:NaN |
1ddff52a |
1426 | 5:inf:NaN |
1427 | -inf:5:NaN |
1428 | 5:-inf:NaN |
07d34614 |
1429 | &bmodpow |
1430 | # format: number:exponent:modulus:result |
1431 | # bmodpow Data errors |
1432 | abc:abc:abc:NaN |
1433 | 5:abc:abc:NaN |
1434 | abc:5:abc:NaN |
1435 | abc:abc:5:NaN |
1436 | 5:5:abc:NaN |
1437 | 5:abc:5:NaN |
1438 | abc:5:5:NaN |
1439 | # bmodpow Expected results |
1440 | 0:0:2:1 |
1441 | 1:0:2:1 |
1442 | 0:0:1:0 |
1443 | 8:7:5032:3840 |
1444 | 8:-1:5033:4404 |
1445 | 98436739867439843769485798542749827593285729587325:43698764986460981048259837659386739857456983759328457:6943857329857295827698367:3104744730915914415259518 |
1446 | # bmodpow Error cases |
1447 | 8:8:-5:NaN |
1448 | 8:-1:16:NaN |
1449 | inf:5:13:NaN |
1450 | 5:inf:13:NaN |
6854fd01 |
1451 | &bmod |
1452 | # inf handling, see table in doc |
1453 | 0:inf:0 |
1454 | 0:-inf:0 |
1455 | 5:inf:5 |
1456 | 5:-inf:5 |
1457 | -5:inf:-5 |
1458 | -5:-inf:-5 |
1459 | inf:5:0 |
1460 | -inf:5:0 |
1461 | inf:-5:0 |
1462 | -inf:-5:0 |
1463 | 5:5:0 |
1464 | -5:-5:0 |
b3abae2a |
1465 | inf:inf:NaN |
1466 | -inf:-inf:NaN |
1467 | -inf:inf:NaN |
1468 | inf:-inf:NaN |
6854fd01 |
1469 | 8:0:8 |
1470 | inf:0:inf |
1471 | # exceptions to reminder rule |
1472 | -inf:0:-inf |
1473 | -8:0:-8 |
1474 | 0:0:NaN |
1475 | abc:abc:NaN |
61f5c3f5 |
1476 | abc:1:abc:NaN |
1477 | 1:abc:NaN |
1478 | 0:0:NaN |
1479 | 0:1:0 |
1480 | 1:0:1 |
1481 | 0:-1:0 |
1482 | -1:0:-1 |
1483 | 1:1:0 |
1484 | -1:-1:0 |
1485 | 1:-1:0 |
1486 | -1:1:0 |
1487 | 1:2:1 |
1488 | 2:1:0 |
1489 | 1000000000:9:1 |
1490 | 2000000000:9:2 |
1491 | 3000000000:9:3 |
1492 | 4000000000:9:4 |
1493 | 5000000000:9:5 |
1494 | 6000000000:9:6 |
1495 | 7000000000:9:7 |
1496 | 8000000000:9:8 |
1497 | 9000000000:9:0 |
1498 | 35500000:113:33 |
1499 | 71000000:226:66 |
1500 | 106500000:339:99 |
1501 | 1000000000:3:1 |
1502 | 10:5:0 |
1503 | 100:4:0 |
1504 | 1000:8:0 |
1505 | 10000:16:0 |
1506 | 999999999999:9:0 |
1507 | 999999999999:99:0 |
1508 | 999999999999:999:0 |
1509 | 999999999999:9999:0 |
1510 | 999999999999999:99999:0 |
1511 | -9:+5:1 |
6854fd01 |
1512 | +9:-5:-1 |
1513 | -9:-5:-4 |
1514 | -5:3:1 |
1515 | -2:3:1 |
1516 | 4:3:1 |
1517 | 1:3:1 |
1518 | -5:-3:-2 |
1519 | -2:-3:-2 |
1520 | 4:-3:-2 |
1521 | 1:-3:-2 |
1522 | 4095:4095:0 |
027dc388 |
1523 | 100041000510123:3:0 |
1524 | 152403346:12345:4321 |
b3abae2a |
1525 | 9:5:4 |
28df3e88 |
1526 | # test shortcuts in Calc |
1527 | # 1ex % 9 is always == 1, 1ex % 113 is != 1 for x = (4..9), 1ex % 10 = 0 |
1528 | 1234:9:1 |
1529 | 123456:9:3 |
1530 | 12345678:9:0 |
1531 | 1234567891:9:1 |
1532 | 123456789123:9:6 |
1533 | 12345678912345:9:6 |
1534 | 1234567891234567:9:1 |
1535 | 123456789123456789:9:0 |
1536 | 1234:10:4 |
1537 | 123456:10:6 |
1538 | 12345678:10:8 |
1539 | 1234567891:10:1 |
1540 | 123456789123:10:3 |
1541 | 12345678912345:10:5 |
1542 | 1234567891234567:10:7 |
1543 | 123456789123456789:10:9 |
1544 | 1234:113:104 |
1545 | 123456:113:60 |
1546 | 12345678:113:89 |
1547 | 1234567891:113:64 |
1548 | 123456789123:113:95 |
1549 | 12345678912345:113:53 |
1550 | 1234567891234567:113:56 |
1551 | 123456789123456789:113:39 |
07d34614 |
1552 | # bug in bmod() not modifying the variable in place |
1553 | -629:5033:4404 |
6854fd01 |
1554 | &bgcd |
1555 | abc:abc:NaN |
1556 | abc:+0:NaN |
1557 | +0:abc:NaN |
61f5c3f5 |
1558 | +0:+0:0 |
1559 | +0:+1:1 |
1560 | +1:+0:1 |
1561 | +1:+1:1 |
1562 | +2:+3:1 |
1563 | +3:+2:1 |
1564 | -3:+2:1 |
1565 | 100:625:25 |
1566 | 4096:81:1 |
1567 | 1034:804:2 |
1568 | 27:90:56:1 |
1569 | 27:90:54:9 |
6854fd01 |
1570 | &blcm |
1571 | abc:abc:NaN |
1572 | abc:+0:NaN |
1573 | +0:abc:NaN |
1574 | +0:+0:NaN |
61f5c3f5 |
1575 | +1:+0:0 |
1576 | +0:+1:0 |
1577 | +27:+90:270 |
1578 | +1034:+804:415668 |
6854fd01 |
1579 | &band |
1580 | abc:abc:NaN |
1581 | abc:0:NaN |
1582 | 0:abc:NaN |
1583 | 1:2:0 |
1584 | 3:2:2 |
61f5c3f5 |
1585 | +8:+2:0 |
1586 | +281474976710656:0:0 |
1587 | +281474976710656:1:0 |
1588 | +281474976710656:+281474976710656:281474976710656 |
6854fd01 |
1589 | -2:-3:-4 |
1590 | -1:-1:-1 |
1591 | -6:-6:-6 |
1592 | -7:-4:-8 |
1593 | -7:4:0 |
1594 | -4:7:4 |
394e6ffb |
1595 | # equal arguments are treated special, so also do some test with unequal ones |
1596 | 0xFFFF:0xFFFF:0x0xFFFF |
1597 | 0xFFFFFF:0xFFFFFF:0x0xFFFFFF |
1598 | 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF |
1599 | 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF |
1600 | 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF |
1601 | 0xF0F0:0xF0F0:0x0xF0F0 |
1602 | 0x0F0F:0x0F0F:0x0x0F0F |
1603 | 0xF0F0F0:0xF0F0F0:0x0xF0F0F0 |
1604 | 0x0F0F0F:0x0F0F0F:0x0x0F0F0F |
1605 | 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0 |
1606 | 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F |
1607 | 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0 |
1608 | 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F |
1609 | 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0 |
1610 | 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F |
1611 | 0x1F0F0F0F0F0F:0x3F0F0F0F0F0F:0x0x1F0F0F0F0F0F |
6854fd01 |
1612 | &bior |
1613 | abc:abc:NaN |
1614 | abc:0:NaN |
1615 | 0:abc:NaN |
1616 | 1:2:3 |
61f5c3f5 |
1617 | +8:+2:10 |
1618 | +281474976710656:0:281474976710656 |
1619 | +281474976710656:1:281474976710657 |
1620 | +281474976710656:281474976710656:281474976710656 |
6854fd01 |
1621 | -2:-3:-1 |
1622 | -1:-1:-1 |
1623 | -6:-6:-6 |
1624 | -7:4:-3 |
1625 | -4:7:-1 |
394e6ffb |
1626 | # equal arguments are treated special, so also do some test with unequal ones |
1627 | 0xFFFF:0xFFFF:0x0xFFFF |
1628 | 0xFFFFFF:0xFFFFFF:0x0xFFFFFF |
1629 | 0xFFFFFFFF:0xFFFFFFFF:0x0xFFFFFFFF |
1630 | 0xFFFFFFFFFF:0xFFFFFFFFFF:0x0xFFFFFFFFFF |
1631 | 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF |
1632 | 0:0xFFFF:0x0xFFFF |
1633 | 0:0xFFFFFF:0x0xFFFFFF |
1634 | 0:0xFFFFFFFF:0x0xFFFFFFFF |
1635 | 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF |
1636 | 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF |
1637 | 0xFFFF:0:0x0xFFFF |
1638 | 0xFFFFFF:0:0x0xFFFFFF |
1639 | 0xFFFFFFFF:0:0x0xFFFFFFFF |
1640 | 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF |
1641 | 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF |
1642 | 0xF0F0:0xF0F0:0x0xF0F0 |
1643 | 0x0F0F:0x0F0F:0x0x0F0F |
1644 | 0xF0F0:0x0F0F:0x0xFFFF |
1645 | 0xF0F0F0:0xF0F0F0:0x0xF0F0F0 |
1646 | 0x0F0F0F:0x0F0F0F:0x0x0F0F0F |
1647 | 0x0F0F0F:0xF0F0F0:0x0xFFFFFF |
1648 | 0xF0F0F0F0:0xF0F0F0F0:0x0xF0F0F0F0 |
1649 | 0x0F0F0F0F:0x0F0F0F0F:0x0x0F0F0F0F |
1650 | 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF |
1651 | 0xF0F0F0F0F0:0xF0F0F0F0F0:0x0xF0F0F0F0F0 |
1652 | 0x0F0F0F0F0F:0x0F0F0F0F0F:0x0x0F0F0F0F0F |
1653 | 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF |
1654 | 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0x0xF0F0F0F0F0F0 |
1655 | 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0x0x0F0F0F0F0F0F |
1656 | 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF |
1657 | 0x1F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF |
6854fd01 |
1658 | &bxor |
1659 | abc:abc:NaN |
1660 | abc:0:NaN |
1661 | 0:abc:NaN |
1662 | 1:2:3 |
61f5c3f5 |
1663 | +8:+2:10 |
1664 | +281474976710656:0:281474976710656 |
1665 | +281474976710656:1:281474976710657 |
1666 | +281474976710656:281474976710656:0 |
6854fd01 |
1667 | -2:-3:3 |
1668 | -1:-1:0 |
1669 | -6:-6:0 |
1670 | -7:4:-3 |
1671 | -4:7:-5 |
1672 | 4:-7:-3 |
1673 | -4:-7:5 |
394e6ffb |
1674 | # equal arguments are treated special, so also do some test with unequal ones |
1675 | 0xFFFF:0xFFFF:0 |
1676 | 0xFFFFFF:0xFFFFFF:0 |
1677 | 0xFFFFFFFF:0xFFFFFFFF:0 |
1678 | 0xFFFFFFFFFF:0xFFFFFFFFFF:0 |
1679 | 0xFFFFFFFFFFFF:0xFFFFFFFFFFFF:0 |
1680 | 0:0xFFFF:0x0xFFFF |
1681 | 0:0xFFFFFF:0x0xFFFFFF |
1682 | 0:0xFFFFFFFF:0x0xFFFFFFFF |
1683 | 0:0xFFFFFFFFFF:0x0xFFFFFFFFFF |
1684 | 0:0xFFFFFFFFFFFF:0x0xFFFFFFFFFFFF |
1685 | 0xFFFF:0:0x0xFFFF |
1686 | 0xFFFFFF:0:0x0xFFFFFF |
1687 | 0xFFFFFFFF:0:0x0xFFFFFFFF |
1688 | 0xFFFFFFFFFF:0:0x0xFFFFFFFFFF |
1689 | 0xFFFFFFFFFFFF:0:0x0xFFFFFFFFFFFF |
1690 | 0xF0F0:0xF0F0:0 |
1691 | 0x0F0F:0x0F0F:0 |
1692 | 0xF0F0:0x0F0F:0x0xFFFF |
1693 | 0xF0F0F0:0xF0F0F0:0 |
1694 | 0x0F0F0F:0x0F0F0F:0 |
1695 | 0x0F0F0F:0xF0F0F0:0x0xFFFFFF |
1696 | 0xF0F0F0F0:0xF0F0F0F0:0 |
1697 | 0x0F0F0F0F:0x0F0F0F0F:0 |
1698 | 0x0F0F0F0F:0xF0F0F0F0:0x0xFFFFFFFF |
1699 | 0xF0F0F0F0F0:0xF0F0F0F0F0:0 |
1700 | 0x0F0F0F0F0F:0x0F0F0F0F0F:0 |
1701 | 0x0F0F0F0F0F:0xF0F0F0F0F0:0x0xFFFFFFFFFF |
1702 | 0xF0F0F0F0F0F0:0xF0F0F0F0F0F0:0 |
1703 | 0x0F0F0F0F0F0F:0x0F0F0F0F0F0F:0 |
1704 | 0x0F0F0F0F0F0F:0xF0F0F0F0F0F0:0x0xFFFFFFFFFFFF |
6854fd01 |
1705 | &bnot |
1706 | abc:NaN |
1707 | +0:-1 |
1708 | +8:-9 |
1709 | +281474976710656:-281474976710657 |
1710 | -1:0 |
1711 | -2:1 |
1712 | -12:11 |
1713 | &digit |
1714 | 0:0:0 |
1715 | 12:0:2 |
1716 | 12:1:1 |
1717 | 123:0:3 |
1718 | 123:1:2 |
1719 | 123:2:1 |
1720 | 123:-1:1 |
1721 | 123:-2:2 |
1722 | 123:-3:3 |
1723 | 123456:0:6 |
1724 | 123456:1:5 |
1725 | 123456:2:4 |
1726 | 123456:3:3 |
1727 | 123456:4:2 |
1728 | 123456:5:1 |
1729 | 123456:-1:1 |
1730 | 123456:-2:2 |
1731 | 123456:-3:3 |
1732 | 100000:-3:0 |
1733 | 100000:0:0 |
1734 | 100000:1:0 |
1735 | &mantissa |
1736 | abc:NaN |
1737 | 1e4:1 |
1738 | 2e0:2 |
1739 | 123:123 |
1740 | -1:-1 |
1741 | -2:-2 |
1742 | +inf:inf |
1743 | -inf:-inf |
1744 | &exponent |
1745 | abc:NaN |
1746 | 1e4:4 |
1747 | 2e0:0 |
1748 | 123:0 |
1749 | -1:0 |
1750 | -2:0 |
1751 | 0:1 |
1752 | +inf:inf |
1753 | -inf:inf |
1754 | &parts |
1755 | abc:NaN,NaN |
1756 | 1e4:1,4 |
1757 | 2e0:2,0 |
1758 | 123:123,0 |
1759 | -1:-1,0 |
1760 | -2:-2,0 |
1761 | 0:0,1 |
1762 | +inf:inf,inf |
1763 | -inf:-inf,inf |
b3abae2a |
1764 | &bfac |
1765 | -1:NaN |
1766 | NaNfac:NaN |
1767 | +inf:NaN |
1768 | -inf:NaN |
1769 | 0:1 |
1770 | 1:1 |
1771 | 2:2 |
1772 | 3:6 |
1773 | 4:24 |
1774 | 5:120 |
1775 | 6:720 |
1776 | 10:3628800 |
1777 | 11:39916800 |
1778 | 12:479001600 |
6854fd01 |
1779 | &bpow |
1780 | abc:12:NaN |
1781 | 12:abc:NaN |
1782 | 0:0:1 |
1783 | 0:1:0 |
1784 | 0:2:0 |
1785 | 0:-1:NaN |
1786 | 0:-2:NaN |
1787 | 1:0:1 |
1788 | 1:1:1 |
1789 | 1:2:1 |
1790 | 1:3:1 |
1791 | 1:-1:1 |
1792 | 1:-2:1 |
1793 | 1:-3:1 |
1794 | 2:0:1 |
1795 | 2:1:2 |
1796 | 2:2:4 |
1797 | 2:3:8 |
1798 | 3:3:27 |
1799 | 2:-1:NaN |
1800 | -2:-1:NaN |
1801 | 2:-2:NaN |
1802 | -2:-2:NaN |
1803 | +inf:1234500012:inf |
1804 | -inf:1234500012:-inf |
1805 | +inf:-12345000123:inf |
1806 | -inf:-12345000123:-inf |
1807 | # 1 ** -x => 1 / (1 ** x) |
1808 | -1:0:1 |
1809 | -2:0:1 |
1810 | -1:1:-1 |
1811 | -1:2:1 |
1812 | -1:3:-1 |
1813 | -1:4:1 |
1814 | -1:5:-1 |
1815 | -1:-1:-1 |
1816 | -1:-2:1 |
1817 | -1:-3:-1 |
1818 | -1:-4:1 |
1819 | 10:2:100 |
1820 | 10:3:1000 |
1821 | 10:4:10000 |
1822 | 10:5:100000 |
1823 | 10:6:1000000 |
1824 | 10:7:10000000 |
1825 | 10:8:100000000 |
1826 | 10:9:1000000000 |
1827 | 10:20:100000000000000000000 |
1828 | 123456:2:15241383936 |
1829 | &length |
1830 | 100:3 |
1831 | 10:2 |
1832 | 1:1 |
1833 | 0:1 |
1834 | 12345:5 |
1835 | 10000000000000000:17 |
1836 | -123:3 |
1837 | 215960156869840440586892398248:30 |
1838 | &bsqrt |
394e6ffb |
1839 | 145:12 |
6854fd01 |
1840 | 144:12 |
394e6ffb |
1841 | 143:11 |
6854fd01 |
1842 | 16:4 |
394e6ffb |
1843 | 170:13 |
1844 | 169:13 |
1845 | 168:12 |
6854fd01 |
1846 | 4:2 |
394e6ffb |
1847 | 3:1 |
6854fd01 |
1848 | 2:1 |
394e6ffb |
1849 | 9:3 |
6854fd01 |
1850 | 12:3 |
1851 | 256:16 |
1852 | 100000000:10000 |
1853 | 4000000000000:2000000 |
394e6ffb |
1854 | 152399026:12345 |
1855 | 152399025:12345 |
1856 | 152399024:12344 |
6854fd01 |
1857 | 1:1 |
1858 | 0:0 |
1859 | -2:NaN |
394e6ffb |
1860 | -123:NaN |
6854fd01 |
1861 | Nan:NaN |
394e6ffb |
1862 | +inf:NaN |
6854fd01 |
1863 | &bround |
1864 | $round_mode('trunc') |
1865 | 0:12:0 |
1866 | NaNbround:12:NaN |
1867 | +inf:12:inf |
1868 | -inf:12:-inf |
1869 | 1234:0:1234 |
1870 | 1234:2:1200 |
1871 | 123456:4:123400 |
1872 | 123456:5:123450 |
1873 | 123456:6:123456 |
61f5c3f5 |
1874 | +10123456789:5:10123000000 |
6854fd01 |
1875 | -10123456789:5:-10123000000 |
61f5c3f5 |
1876 | +10123456789:9:10123456700 |
6854fd01 |
1877 | -10123456789:9:-10123456700 |
61f5c3f5 |
1878 | +101234500:6:101234000 |
6854fd01 |
1879 | -101234500:6:-101234000 |
61f5c3f5 |
1880 | #+101234500:-4:101234000 |
6854fd01 |
1881 | #-101234500:-4:-101234000 |
1882 | $round_mode('zero') |
61f5c3f5 |
1883 | +20123456789:5:20123000000 |
6854fd01 |
1884 | -20123456789:5:-20123000000 |
61f5c3f5 |
1885 | +20123456789:9:20123456800 |
6854fd01 |
1886 | -20123456789:9:-20123456800 |
61f5c3f5 |
1887 | +201234500:6:201234000 |
6854fd01 |
1888 | -201234500:6:-201234000 |
61f5c3f5 |
1889 | #+201234500:-4:201234000 |
6854fd01 |
1890 | #-201234500:-4:-201234000 |
1891 | +12345000:4:12340000 |
1892 | -12345000:4:-12340000 |
1893 | $round_mode('+inf') |
61f5c3f5 |
1894 | +30123456789:5:30123000000 |
6854fd01 |
1895 | -30123456789:5:-30123000000 |
61f5c3f5 |
1896 | +30123456789:9:30123456800 |
6854fd01 |
1897 | -30123456789:9:-30123456800 |
61f5c3f5 |
1898 | +301234500:6:301235000 |
6854fd01 |
1899 | -301234500:6:-301234000 |
61f5c3f5 |
1900 | #+301234500:-4:301235000 |
6854fd01 |
1901 | #-301234500:-4:-301234000 |
1902 | +12345000:4:12350000 |
1903 | -12345000:4:-12340000 |
1904 | $round_mode('-inf') |
61f5c3f5 |
1905 | +40123456789:5:40123000000 |
6854fd01 |
1906 | -40123456789:5:-40123000000 |
61f5c3f5 |
1907 | +40123456789:9:40123456800 |
6854fd01 |
1908 | -40123456789:9:-40123456800 |
61f5c3f5 |
1909 | +401234500:6:401234000 |
1910 | +401234500:6:401234000 |
6854fd01 |
1911 | #-401234500:-4:-401235000 |
1912 | #-401234500:-4:-401235000 |
1913 | +12345000:4:12340000 |
1914 | -12345000:4:-12350000 |
1915 | $round_mode('odd') |
61f5c3f5 |
1916 | +50123456789:5:50123000000 |
6854fd01 |
1917 | -50123456789:5:-50123000000 |
61f5c3f5 |
1918 | +50123456789:9:50123456800 |
6854fd01 |
1919 | -50123456789:9:-50123456800 |
61f5c3f5 |
1920 | +501234500:6:501235000 |
6854fd01 |
1921 | -501234500:6:-501235000 |
61f5c3f5 |
1922 | #+501234500:-4:501235000 |
6854fd01 |
1923 | #-501234500:-4:-501235000 |
1924 | +12345000:4:12350000 |
1925 | -12345000:4:-12350000 |
1926 | $round_mode('even') |
61f5c3f5 |
1927 | +60123456789:5:60123000000 |
6854fd01 |
1928 | -60123456789:5:-60123000000 |
61f5c3f5 |
1929 | +60123456789:9:60123456800 |
6854fd01 |
1930 | -60123456789:9:-60123456800 |
61f5c3f5 |
1931 | +601234500:6:601234000 |
6854fd01 |
1932 | -601234500:6:-601234000 |
61f5c3f5 |
1933 | #+601234500:-4:601234000 |
6854fd01 |
1934 | #-601234500:-4:-601234000 |
1935 | #-601234500:-9:0 |
1936 | #-501234500:-9:0 |
1937 | #-601234500:-8:0 |
1938 | #-501234500:-8:0 |
1939 | +1234567:7:1234567 |
1940 | +1234567:6:1234570 |
1941 | +12345000:4:12340000 |
1942 | -12345000:4:-12340000 |
1943 | &is_zero |
1944 | 0:1 |
1945 | NaNzero:0 |
1946 | +inf:0 |
1947 | -inf:0 |
1948 | 123:0 |
1949 | -1:0 |
1950 | 1:0 |
1951 | &is_one |
1952 | 0:0 |
1953 | NaNone:0 |
1954 | +inf:0 |
1955 | -inf:0 |
1956 | 1:1 |
1957 | 2:0 |
1958 | -1:0 |
1959 | -2:0 |
1960 | # floor and ceil tests are pretty pointless in integer space...but play safe |
1961 | &bfloor |
1962 | 0:0 |
1963 | NaNfloor:NaN |
1964 | +inf:inf |
1965 | -inf:-inf |
1966 | -1:-1 |
1967 | -2:-2 |
1968 | 2:2 |
1969 | 3:3 |
1970 | abc:NaN |
1971 | &bceil |
1972 | NaNceil:NaN |
1973 | +inf:inf |
1974 | -inf:-inf |
1975 | 0:0 |
1976 | -1:-1 |
1977 | -2:-2 |
1978 | 2:2 |
1979 | 3:3 |
1980 | abc:NaN |
1981 | &as_hex |
1982 | 128:0x80 |
1983 | -128:-0x80 |
1984 | 0:0x0 |
1985 | -0:0x0 |
1986 | 1:0x1 |
1987 | 0x123456789123456789:0x123456789123456789 |
1988 | +inf:inf |
1989 | -inf:-inf |
1990 | NaNas_hex:NaN |
1991 | &as_bin |
1992 | 128:0b10000000 |
1993 | -128:-0b10000000 |
1994 | 0:0b0 |
1995 | -0:0b0 |
1996 | 1:0b1 |
1997 | 0b1010111101010101010110110110110110101:0b1010111101010101010110110110110110101 |
1ddff52a |
1998 | 0x123456789123456789:0b100100011010001010110011110001001000100100011010001010110011110001001 |
6854fd01 |
1999 | +inf:inf |
2000 | -inf:-inf |
2001 | NaNas_bin:NaN |