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