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