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