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