Commit | Line | Data |
58cde26e |
1 | #!/usr/bin/perl -w |
748a9306 |
2 | |
58cde26e |
3 | use strict; |
4 | use Test; |
5 | |
6 | BEGIN |
7 | { |
8 | $| = 1; |
9 | # chdir 't' if -d 't'; |
10 | unshift @INC, '../lib'; # for running manually |
0716bf9b |
11 | plan tests => 1222; |
58cde26e |
12 | } |
0716bf9b |
13 | my $version = '1.36'; # for $VERSION tests, match current release (by hand!) |
58cde26e |
14 | |
15 | ############################################################################## |
16 | # for testing inheritance of _swap |
17 | |
18 | package Math::Foo; |
19 | |
20 | use Math::BigInt; |
21 | use vars qw/@ISA/; |
22 | @ISA = (qw/Math::BigInt/); |
23 | |
24 | use overload |
25 | # customized overload for sub, since original does not use swap there |
26 | '-' => sub { my @a = ref($_[0])->_swap(@_); |
27 | $a[0]->bsub($a[1])}; |
28 | |
29 | sub _swap |
30 | { |
31 | # a fake _swap, which reverses the params |
32 | my $self = shift; # for override in subclass |
33 | if ($_[2]) |
34 | { |
35 | my $c = ref ($_[0] ) || 'Math::Foo'; |
36 | return ( $_[0]->copy(), $_[1] ); |
37 | } |
38 | else |
39 | { |
40 | return ( Math::Foo->new($_[1]), $_[0] ); |
41 | } |
42 | } |
43 | |
44 | ############################################################################## |
45 | package main; |
d1f8c7a4 |
46 | |
748a9306 |
47 | use Math::BigInt; |
0716bf9b |
48 | #use Math::BigInt lib => 'BitVect'; # for testing |
49 | #use Math::BigInt lib => 'Small'; # for testing |
50 | |
51 | my $CALC = Math::BigInt::_core_lib(); |
748a9306 |
52 | |
58cde26e |
53 | my (@args,$f,$try,$x,$y,$z,$a,$exp,$ans,$ans1,@a,$m,$e,$round_mode); |
54 | |
55 | while (<DATA>) |
56 | { |
57 | chop; |
58 | next if /^#/; # skip comments |
59 | if (s/^&//) |
60 | { |
61 | $f = $_; |
62 | } |
63 | elsif (/^\$/) |
64 | { |
65 | $round_mode = $_; |
66 | $round_mode =~ s/^\$/Math::BigInt->/; |
67 | # print "$round_mode\n"; |
68 | } |
69 | else |
70 | { |
71 | @args = split(/:/,$_,99); |
72 | $ans = pop(@args); |
73 | $try = "\$x = Math::BigInt->new(\"$args[0]\");"; |
74 | if ($f eq "bnorm"){ |
75 | # $try .= '$x+0;'; |
58cde26e |
76 | } elsif ($f eq "is_zero") { |
77 | $try .= '$x->is_zero()+0;'; |
78 | } elsif ($f eq "is_one") { |
79 | $try .= '$x->is_one()+0;'; |
80 | } elsif ($f eq "is_odd") { |
81 | $try .= '$x->is_odd()+0;'; |
82 | } elsif ($f eq "is_even") { |
83 | $try .= '$x->is_even()+0;'; |
0716bf9b |
84 | } elsif ($f eq "is_inf") { |
85 | $try .= "\$x->is_inf('$args[1]')+0;"; |
58cde26e |
86 | } elsif ($f eq "binf") { |
87 | $try .= "\$x->binf('$args[1]');"; |
88 | } elsif ($f eq "bfloor") { |
89 | $try .= '$x->bfloor();'; |
90 | } elsif ($f eq "bceil") { |
91 | $try .= '$x->bceil();'; |
58cde26e |
92 | } elsif ($f eq "bsstr") { |
93 | $try .= '$x->bsstr();'; |
94 | } elsif ($f eq "bneg") { |
95 | $try .= '-$x;'; |
96 | } elsif ($f eq "babs") { |
97 | $try .= 'abs $x;'; |
98 | } elsif ($f eq "binc") { |
99 | $try .= '++$x;'; |
100 | } elsif ($f eq "bdec") { |
101 | $try .= '--$x;'; |
102 | }elsif ($f eq "bnot") { |
103 | $try .= '~$x;'; |
104 | }elsif ($f eq "bsqrt") { |
105 | $try .= '$x->bsqrt();'; |
106 | }elsif ($f eq "length") { |
107 | $try .= "\$x->length();"; |
58cde26e |
108 | }elsif ($f eq "exponent"){ |
109 | $try .= '$x = $x->exponent()->bstr();'; |
110 | }elsif ($f eq "mantissa"){ |
111 | $try .= '$x = $x->mantissa()->bstr();'; |
112 | }elsif ($f eq "parts"){ |
113 | $try .= "(\$m,\$e) = \$x->parts();"; |
114 | $try .= '$m = $m->bstr(); $m = "NaN" if !defined $m;'; |
115 | $try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;'; |
116 | $try .= '"$m,$e";'; |
117 | } else { |
0716bf9b |
118 | $try .= "\$y = new Math::BigInt ('$args[1]');"; |
58cde26e |
119 | if ($f eq "bcmp"){ |
120 | $try .= '$x <=> $y;'; |
0716bf9b |
121 | }elsif ($f eq "bround") { |
122 | $try .= "$round_mode; \$x->bround(\$y);"; |
58cde26e |
123 | }elsif ($f eq "bacmp"){ |
0716bf9b |
124 | $try .= "\$x->bacmp(\$y);"; |
58cde26e |
125 | }elsif ($f eq "badd"){ |
126 | $try .= "\$x + \$y;"; |
127 | }elsif ($f eq "bsub"){ |
128 | $try .= "\$x - \$y;"; |
129 | }elsif ($f eq "bmul"){ |
130 | $try .= "\$x * \$y;"; |
131 | }elsif ($f eq "bdiv"){ |
132 | $try .= "\$x / \$y;"; |
133 | }elsif ($f eq "bmod"){ |
134 | $try .= "\$x % \$y;"; |
135 | }elsif ($f eq "bgcd") |
136 | { |
137 | if (defined $args[2]) |
138 | { |
139 | $try .= " \$z = new Math::BigInt \"$args[2]\"; "; |
140 | } |
141 | $try .= "Math::BigInt::bgcd(\$x, \$y"; |
142 | $try .= ", \$z" if (defined $args[2]); |
143 | $try .= " );"; |
144 | } |
145 | elsif ($f eq "blcm") |
146 | { |
147 | if (defined $args[2]) |
148 | { |
149 | $try .= " \$z = new Math::BigInt \"$args[2]\"; "; |
150 | } |
151 | $try .= "Math::BigInt::blcm(\$x, \$y"; |
152 | $try .= ", \$z" if (defined $args[2]); |
153 | $try .= " );"; |
154 | }elsif ($f eq "blsft"){ |
155 | if (defined $args[2]) |
156 | { |
157 | $try .= "\$x->blsft(\$y,$args[2]);"; |
158 | } |
159 | else |
160 | { |
161 | $try .= "\$x << \$y;"; |
162 | } |
163 | }elsif ($f eq "brsft"){ |
164 | if (defined $args[2]) |
165 | { |
166 | $try .= "\$x->brsft(\$y,$args[2]);"; |
167 | } |
168 | else |
169 | { |
170 | $try .= "\$x >> \$y;"; |
171 | } |
172 | }elsif ($f eq "band"){ |
173 | $try .= "\$x & \$y;"; |
174 | }elsif ($f eq "bior"){ |
175 | $try .= "\$x | \$y;"; |
176 | }elsif ($f eq "bxor"){ |
177 | $try .= "\$x ^ \$y;"; |
178 | }elsif ($f eq "bpow"){ |
179 | $try .= "\$x ** \$y;"; |
180 | }elsif ($f eq "digit"){ |
181 | $try = "\$x = Math::BigInt->new(\"$args[0]\"); \$x->digit($args[1]);"; |
182 | } else { warn "Unknown op '$f'"; } |
183 | } |
184 | # print "trying $try\n"; |
185 | $ans1 = eval $try; |
186 | $ans =~ s/^[+]([0-9])/$1/; # remove leading '+' |
187 | if ($ans eq "") |
188 | { |
189 | ok_undef ($ans1); |
190 | } |
191 | else |
192 | { |
193 | #print "try: $try ans: $ans1 $ans\n"; |
194 | print "# Tried: '$try'\n" if !ok ($ans1, $ans); |
195 | } |
196 | # check internal state of number objects |
0716bf9b |
197 | is_valid($ans1,$f) if ref $ans1; |
58cde26e |
198 | } |
199 | } # endwhile data tests |
200 | close DATA; |
201 | |
b22b3e31 |
202 | # XXX Tels 06/29/2001 following tests never fail or do not work :( |
0716bf9b |
203 | |
204 | # test whether use Math::BigInt qw/version/ works |
205 | $try = "use Math::BigInt ($version.'1');"; |
206 | $try .= ' $x = Math::BigInt->new(123); $x = "$x";'; |
58cde26e |
207 | $ans1 = eval $try; |
0716bf9b |
208 | ok_undef ( $_ ); # should result in error! |
58cde26e |
209 | |
0716bf9b |
210 | # test whether constant works or not, also test for qw($version) |
211 | $try = "use Math::BigInt ($version,'babs',':constant');"; |
212 | $try .= ' $x = 2**150; babs($x); $x = "$x";'; |
213 | $ans1 = eval $try; |
58cde26e |
214 | ok ( $ans1, "1427247692705959881058285969449495136382746624"); |
215 | |
0716bf9b |
216 | # test wether Math::BigInt::Small via use works (w/ dff. spellings of calc) |
217 | #$try = "use Math::BigInt ($version,'CALC','Small');"; |
218 | #$try .= ' $x = 2**10; $x = "$x";'; |
219 | #$ans1 = eval $try; |
220 | #ok ( $ans1, "1024"); |
221 | #$try = "use Math::BigInt ($version,'cAlC','Math::BigInt::Small');"; |
222 | #$try .= ' $x = 2**10; $x = "$x";'; |
223 | #$ans1 = eval $try; |
224 | #ok ( $ans1, "1024"); |
225 | # test wether calc => undef (array element not existing) works |
226 | #$try = "use Math::BigInt ($version,'CALC');"; |
227 | #$try = "require Math::BigInt; Math::BigInt::import($version,'CALC');"; |
228 | #$try .= ' $x = Math::BigInt->new(2)**10; $x = "$x";'; |
229 | #$ans1 = eval $try; |
230 | #ok ( $ans1, 1024); |
231 | |
58cde26e |
232 | # test some more |
233 | @a = (); |
234 | for (my $i = 1; $i < 10; $i++) |
235 | { |
236 | push @a, $i; |
237 | } |
238 | ok "@a", "1 2 3 4 5 6 7 8 9"; |
239 | |
240 | # test whether selfmultiplication works correctly (result is 2**64) |
241 | $try = '$x = new Math::BigInt "+4294967296";'; |
242 | $try .= '$a = $x->bmul($x);'; |
243 | $ans1 = eval $try; |
244 | print "# Tried: '$try'\n" if !ok ($ans1, Math::BigInt->new(2) ** 64); |
245 | |
0716bf9b |
246 | # test whether op destroys args or not (should better not) |
58cde26e |
247 | |
248 | $x = new Math::BigInt (3); |
249 | $y = new Math::BigInt (4); |
250 | $z = $x & $y; |
251 | ok ($x,3); |
252 | ok ($y,4); |
253 | ok ($z,0); |
254 | $z = $x | $y; |
255 | ok ($x,3); |
256 | ok ($y,4); |
257 | ok ($z,7); |
258 | $x = new Math::BigInt (1); |
259 | $y = new Math::BigInt (2); |
260 | $z = $x | $y; |
261 | ok ($x,1); |
262 | ok ($y,2); |
263 | ok ($z,3); |
264 | |
265 | $x = new Math::BigInt (5); |
266 | $y = new Math::BigInt (4); |
267 | $z = $x ^ $y; |
268 | ok ($x,5); |
269 | ok ($y,4); |
270 | ok ($z,1); |
271 | |
272 | $x = new Math::BigInt (-5); $y = -$x; |
273 | ok ($x, -5); |
274 | |
275 | $x = new Math::BigInt (-5); $y = abs($x); |
276 | ok ($x, -5); |
277 | |
278 | # check whether overloading cmp works |
279 | $try = "\$x = Math::BigInt->new(0);"; |
280 | $try .= "\$y = 10;"; |
281 | $try .= "'false' if \$x ne \$y;"; |
282 | $ans = eval $try; |
283 | print "# For '$try'\n" if (!ok "$ans" , "false" ); |
284 | |
285 | # we cant test for working cmpt with other objects here, we would need a dummy |
286 | # object with stringify overload for this. see Math::String tests |
287 | |
288 | ############################################################################### |
289 | # check shortcuts |
290 | $try = "\$x = Math::BigInt->new(1); \$x += 9;"; |
291 | $try .= "'ok' if \$x == 10;"; |
292 | $ans = eval $try; |
293 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
294 | |
295 | $try = "\$x = Math::BigInt->new(1); \$x -= 9;"; |
296 | $try .= "'ok' if \$x == -8;"; |
297 | $ans = eval $try; |
298 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
299 | |
300 | $try = "\$x = Math::BigInt->new(1); \$x *= 9;"; |
301 | $try .= "'ok' if \$x == 9;"; |
302 | $ans = eval $try; |
303 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
304 | |
305 | $try = "\$x = Math::BigInt->new(10); \$x /= 2;"; |
306 | $try .= "'ok' if \$x == 5;"; |
307 | $ans = eval $try; |
308 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
309 | |
310 | ############################################################################### |
311 | # check reversed order of arguments |
312 | $try = "\$x = Math::BigInt->new(10); \$x = 2 ** \$x;"; |
313 | $try .= "'ok' if \$x == 1024;"; $ans = eval $try; |
314 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
315 | |
316 | $try = "\$x = Math::BigInt->new(10); \$x = 2 * \$x;"; |
317 | $try .= "'ok' if \$x == 20;"; $ans = eval $try; |
318 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
319 | |
320 | $try = "\$x = Math::BigInt->new(10); \$x = 2 + \$x;"; |
321 | $try .= "'ok' if \$x == 12;"; $ans = eval $try; |
322 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
323 | |
324 | $try = "\$x = Math::BigInt->new(10); \$x = 2 - \$x;"; |
325 | $try .= "'ok' if \$x == -8;"; $ans = eval $try; |
326 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
327 | |
328 | $try = "\$x = Math::BigInt->new(10); \$x = 20 / \$x;"; |
329 | $try .= "'ok' if \$x == 2;"; $ans = eval $try; |
330 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
331 | |
332 | ############################################################################### |
333 | # check badd(4,5) form |
334 | |
335 | $try = "\$x = Math::BigInt::badd(4,5);"; |
336 | $try .= "'ok' if \$x == 9;"; |
337 | $ans = eval $try; |
338 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
339 | |
340 | $try = "\$x = Math::BigInt->badd(4,5);"; |
341 | $try .= "'ok' if \$x == 9;"; |
342 | $ans = eval $try; |
343 | print "# For '$try'\n" if (!ok "$ans" , "ok" ); |
344 | |
345 | ############################################################################### |
346 | # check proper length of internal arrays |
347 | |
0716bf9b |
348 | $x = Math::BigInt->new(99999); is_valid($x); |
349 | $x += 1; ok ($x,100000); is_valid($x); |
350 | $x -= 1; ok ($x,99999); is_valid($x); |
58cde26e |
351 | |
352 | ############################################################################### |
b22b3e31 |
353 | # check numify, these tests only make sense with Math::BigInt::Calc, since |
0716bf9b |
354 | # only this uses $BASE |
58cde26e |
355 | |
0716bf9b |
356 | my $BASE = int(1e5); # should access Math::BigInt::Calc::BASE |
58cde26e |
357 | $x = Math::BigInt->new($BASE-1); ok ($x->numify(),$BASE-1); |
358 | $x = Math::BigInt->new(-($BASE-1)); ok ($x->numify(),-($BASE-1)); |
359 | $x = Math::BigInt->new($BASE); ok ($x->numify(),$BASE); |
360 | $x = Math::BigInt->new(-$BASE); ok ($x->numify(),-$BASE); |
361 | $x = Math::BigInt->new( -($BASE*$BASE*1+$BASE*1+1) ); |
362 | ok($x->numify(),-($BASE*$BASE*1+$BASE*1+1)); |
363 | |
364 | ############################################################################### |
365 | # test bug in _digits with length($c[-1]) where $c[-1] was "00001" instead of 1 |
366 | |
367 | $x = Math::BigInt->new(99998); $x++; $x++; $x++; $x++; |
368 | if ($x > 100000) { ok (1,1) } else { ok ("$x < 100000","$x > 100000"); } |
369 | |
370 | $x = Math::BigInt->new(100003); $x++; |
371 | $y = Math::BigInt->new(1000000); |
372 | if ($x < 1000000) { ok (1,1) } else { ok ("$x > 1000000","$x < 1000000"); } |
373 | |
374 | ############################################################################### |
375 | # bug in sub where number with at least 6 trailing zeros after any op failed |
376 | |
377 | $x = Math::BigInt->new(123456); $z = Math::BigInt->new(10000); $z *= 10; |
378 | $x -= $z; |
379 | ok ($z, 100000); |
380 | ok ($x, 23456); |
381 | |
382 | ############################################################################### |
383 | # bug with rest "-0" in div, causing further div()s to fail |
384 | |
0716bf9b |
385 | $x = Math::BigInt->new('-322056000'); ($x,$y) = $x->bdiv('-12882240'); |
58cde26e |
386 | |
0716bf9b |
387 | ok ($y,'0','not -0'); # not '-0' |
58cde26e |
388 | is_valid($y); |
389 | |
390 | ############################################################################### |
391 | # check undefs: NOT DONE YET |
392 | |
393 | ############################################################################### |
394 | # bool |
395 | |
396 | $x = Math::BigInt->new(1); if ($x) { ok (1,1); } else { ok($x,'to be true') } |
397 | $x = Math::BigInt->new(0); if (!$x) { ok (1,1); } else { ok($x,'to be false') } |
398 | |
399 | ############################################################################### |
400 | # objectify() |
401 | |
402 | @args = Math::BigInt::objectify(2,4,5); |
403 | ok (scalar @args,3); # 'Math::BigInt', 4, 5 |
404 | ok ($args[0],'Math::BigInt'); |
405 | ok ($args[1],4); |
406 | ok ($args[2],5); |
407 | |
408 | @args = Math::BigInt::objectify(0,4,5); |
409 | ok (scalar @args,3); # 'Math::BigInt', 4, 5 |
410 | ok ($args[0],'Math::BigInt'); |
411 | ok ($args[1],4); |
412 | ok ($args[2],5); |
413 | |
414 | @args = Math::BigInt::objectify(2,4,5); |
415 | ok (scalar @args,3); # 'Math::BigInt', 4, 5 |
416 | ok ($args[0],'Math::BigInt'); |
417 | ok ($args[1],4); |
418 | ok ($args[2],5); |
419 | |
420 | @args = Math::BigInt::objectify(2,4,5,6,7); |
421 | ok (scalar @args,5); # 'Math::BigInt', 4, 5, 6, 7 |
422 | ok ($args[0],'Math::BigInt'); |
423 | ok ($args[1],4); ok (ref($args[1]),$args[0]); |
424 | ok ($args[2],5); ok (ref($args[2]),$args[0]); |
425 | ok ($args[3],6); ok (ref($args[3]),''); |
426 | ok ($args[4],7); ok (ref($args[4]),''); |
427 | |
428 | @args = Math::BigInt::objectify(2,'Math::BigInt',4,5,6,7); |
429 | ok (scalar @args,5); # 'Math::BigInt', 4, 5, 6, 7 |
430 | ok ($args[0],'Math::BigInt'); |
431 | ok ($args[1],4); ok (ref($args[1]),$args[0]); |
432 | ok ($args[2],5); ok (ref($args[2]),$args[0]); |
433 | ok ($args[3],6); ok (ref($args[3]),''); |
434 | ok ($args[4],7); ok (ref($args[4]),''); |
435 | |
436 | ############################################################################### |
b22b3e31 |
437 | # test for floating-point input (other tests in bnorm() below) |
58cde26e |
438 | |
439 | $z = 1050000000000000; # may be int on systems with 64bit? |
0716bf9b |
440 | $x = Math::BigInt->new($z); ok ($x->bsstr(),'105e+13'); # not 1.03e+15 |
441 | $z = 1e+129; # definitely a float (may fail on UTS) |
442 | $x = Math::BigInt->new($z); ok ($x->bsstr(),$z); |
58cde26e |
443 | |
444 | ############################################################################### |
445 | # prime number tests, also test for **= and length() |
446 | # found on: http://www.utm.edu/research/primes/notes/by_year.html |
447 | |
448 | # ((2^148)-1)/17 |
449 | $x = Math::BigInt->new(2); $x **= 148; $x++; $x = $x / 17; |
450 | ok ($x,"20988936657440586486151264256610222593863921"); |
451 | ok ($x->length(),length "20988936657440586486151264256610222593863921"); |
452 | |
453 | # MM7 = 2^127-1 |
454 | $x = Math::BigInt->new(2); $x **= 127; $x--; |
455 | ok ($x,"170141183460469231731687303715884105727"); |
456 | |
457 | # I am afraid the following is not yet possible due to slowness |
458 | # Also, testing for 2 meg output is a bit hard ;) |
459 | #$x = new Math::BigInt(2); $x **= 6972593; $x--; |
460 | |
0716bf9b |
461 | # 593573509*2^332162+1 has exactly 1,000,000 digits |
b22b3e31 |
462 | # takes about 24 mins on 300 Mhz, so cannot be done yet ;) |
58cde26e |
463 | #$x = Math::BigInt->new(2); $x **= 332162; $x *= "593573509"; $x++; |
0716bf9b |
464 | #ok ($x->length(),1_000_000); |
58cde26e |
465 | |
466 | ############################################################################### |
467 | # inheritance and overriding of _swap |
468 | |
469 | $x = Math::Foo->new(5); |
470 | $x = $x - 8; # 8 - 5 instead of 5-8 |
471 | ok ($x,3); |
472 | ok (ref($x),'Math::Foo'); |
473 | |
474 | $x = Math::Foo->new(5); |
475 | $x = 8 - $x; # 5 - 8 instead of 8 - 5 |
476 | ok ($x,-3); |
477 | ok (ref($x),'Math::Foo'); |
478 | |
479 | ############################################################################### |
480 | # all tests done |
481 | |
58cde26e |
482 | ############################################################################### |
483 | # Perl 5.005 does not like ok ($x,undef) |
484 | |
485 | sub ok_undef |
486 | { |
487 | my $x = shift; |
488 | |
489 | ok (1,1) and return if !defined $x; |
490 | ok ($x,'undef'); |
491 | } |
492 | |
493 | ############################################################################### |
494 | # sub to check validity of a BigInt internally, to ensure that no op leaves a |
495 | # number object in an invalid state (f.i. "-0") |
496 | |
497 | sub is_valid |
498 | { |
0716bf9b |
499 | my ($x,$f) = @_; |
58cde26e |
500 | |
0716bf9b |
501 | my $e = 0; # error? |
58cde26e |
502 | # ok as reference? |
0716bf9b |
503 | $e = 'Not a reference to Math::BigInt' if !ref($x); |
58cde26e |
504 | |
505 | # has ok sign? |
0716bf9b |
506 | $e = "Illegal sign $x->{sign} (expected: '+', '-', '-inf', '+inf' or 'NaN'" |
507 | if $e eq '0' && $x->{sign} !~ /^(\+|-|\+inf|-inf|NaN)$/; |
58cde26e |
508 | |
0716bf9b |
509 | $e = "-0 is invalid!" if $e ne '0' && $x->{sign} eq '-' && $x == 0; |
510 | $e = $CALC->_check($x->{value}) if $e eq '0'; |
58cde26e |
511 | |
0716bf9b |
512 | # test done, see if error did crop up |
513 | ok (1,1), return if ($e eq '0'); |
58cde26e |
514 | |
0716bf9b |
515 | ok (1,$e." op '$f'"); |
a99f8827 |
516 | } |
58cde26e |
517 | |
748a9306 |
518 | __END__ |
0716bf9b |
519 | &is_odd |
520 | abc:0 |
521 | 0:0 |
522 | 1:1 |
523 | 3:1 |
524 | -1:1 |
525 | -3:1 |
526 | 10000001:1 |
527 | 10000002:0 |
528 | 2:0 |
529 | &is_even |
530 | abc:0 |
531 | 0:1 |
532 | 1:0 |
533 | 3:0 |
534 | -1:0 |
535 | -3:0 |
536 | 10000001:0 |
537 | 10000002:1 |
538 | 2:1 |
539 | &bacmp |
540 | +0:-0:0 |
541 | +0:+1:-1 |
542 | -1:+1:0 |
543 | +1:-1:0 |
544 | -1:+2:-1 |
545 | +2:-1:1 |
546 | -123456789:+987654321:-1 |
547 | +123456789:-987654321:-1 |
548 | +987654321:+123456789:1 |
549 | -987654321:+123456789:1 |
550 | -123:+4567889:-1 |
748a9306 |
551 | &bnorm |
0716bf9b |
552 | 123:123 |
58cde26e |
553 | # binary input |
554 | 0babc:NaN |
555 | 0b123:NaN |
556 | 0b0:0 |
557 | -0b0:0 |
558 | -0b1:-1 |
559 | 0b0001:1 |
560 | 0b001:1 |
561 | 0b011:3 |
562 | 0b101:5 |
563 | 0b1000000000000000000000000000000:1073741824 |
564 | # hex input |
565 | -0x0:0 |
566 | 0xabcdefgh:NaN |
567 | 0x1234:4660 |
568 | 0xabcdef:11259375 |
569 | -0xABCDEF:-11259375 |
570 | -0x1234:-4660 |
571 | 0x12345678:305419896 |
572 | # inf input |
573 | +inf:+inf |
574 | -inf:-inf |
575 | 0inf:NaN |
576 | # normal input |
577 | :NaN |
748a9306 |
578 | abc:NaN |
579 | 1 a:NaN |
580 | 1bcd2:NaN |
581 | 11111b:NaN |
582 | +1z:NaN |
583 | -1z:NaN |
58cde26e |
584 | 0:0 |
585 | +0:0 |
586 | +00:0 |
587 | +000:0 |
588 | 000000000000000000:0 |
589 | -0:0 |
590 | -0000:0 |
591 | +1:1 |
592 | +01:1 |
593 | +001:1 |
594 | +00000100000:100000 |
595 | 123456789:123456789 |
748a9306 |
596 | -1:-1 |
597 | -01:-1 |
598 | -001:-1 |
599 | -123456789:-123456789 |
600 | -00000100000:-100000 |
58cde26e |
601 | 1_2_3:123 |
602 | _123:NaN |
603 | _123_:NaN |
604 | _123_:NaN |
605 | 1__23:NaN |
606 | 10000000000E-1_0:1 |
607 | 1E2:100 |
608 | 1E1:10 |
609 | 1E0:1 |
610 | E1:NaN |
611 | E23:NaN |
612 | 1.23E2:123 |
613 | 1.23E1:NaN |
614 | 1.23E-1:NaN |
615 | 100E-1:10 |
616 | # floating point input |
617 | 1.01E2:101 |
618 | 1010E-1:101 |
619 | -1010E0:-1010 |
620 | -1010E1:-10100 |
621 | -1010E-2:NaN |
622 | -1.01E+1:NaN |
623 | -1.01E-1:NaN |
624 | &binf |
625 | 1:+:+inf |
626 | 2:-:-inf |
627 | 3:abc:+inf |
628 | &is_inf |
629 | +inf::1 |
630 | -inf::1 |
631 | abc::0 |
632 | 1::0 |
633 | NaN::0 |
634 | -1::0 |
635 | +inf:-:0 |
636 | +inf:+:1 |
637 | -inf:-:1 |
638 | -inf:+:0 |
0716bf9b |
639 | # it must be exactly /^[+-]inf$/ |
640 | +infinity::0 |
641 | -infinity::0 |
58cde26e |
642 | &blsft |
643 | abc:abc:NaN |
644 | +2:+2:+8 |
645 | +1:+32:+4294967296 |
646 | +1:+48:+281474976710656 |
647 | +8:-2:NaN |
648 | # excercise base 10 |
649 | +12345:4:10:123450000 |
650 | -1234:0:10:-1234 |
651 | +1234:0:10:+1234 |
652 | +2:2:10:200 |
653 | +12:2:10:1200 |
654 | +1234:-3:10:NaN |
655 | 1234567890123:12:10:1234567890123000000000000 |
656 | &brsft |
657 | abc:abc:NaN |
658 | +8:+2:+2 |
659 | +4294967296:+32:+1 |
660 | +281474976710656:+48:+1 |
661 | +2:-2:NaN |
662 | # excercise base 10 |
663 | -1234:0:10:-1234 |
664 | +1234:0:10:+1234 |
665 | +200:2:10:2 |
666 | +1234:3:10:1 |
667 | +1234:2:10:12 |
668 | +1234:-3:10:NaN |
669 | 310000:4:10:31 |
670 | 12300000:5:10:123 |
671 | 1230000000000:10:10:123 |
672 | 09876123456789067890:12:10:9876123 |
673 | 1234561234567890123:13:10:123456 |
674 | &bsstr |
675 | 1e+34:1e+34 |
676 | 123.456E3:123456e+0 |
677 | 100:1e+2 |
678 | abc:NaN |
748a9306 |
679 | &bneg |
680 | abd:NaN |
681 | +0:+0 |
682 | +1:-1 |
683 | -1:+1 |
684 | +123456789:-123456789 |
685 | -123456789:+123456789 |
686 | &babs |
687 | abc:NaN |
688 | +0:+0 |
689 | +1:+1 |
690 | -1:+1 |
691 | +123456789:+123456789 |
692 | -123456789:+123456789 |
693 | &bcmp |
5d7098d5 |
694 | abc:abc: |
695 | abc:+0: |
696 | +0:abc: |
697 | +0:+0:0 |
748a9306 |
698 | -1:+0:-1 |
5d7098d5 |
699 | +0:-1:1 |
700 | +1:+0:1 |
748a9306 |
701 | +0:+1:-1 |
702 | -1:+1:-1 |
5d7098d5 |
703 | +1:-1:1 |
704 | -1:-1:0 |
705 | +1:+1:0 |
706 | +123:+123:0 |
707 | +123:+12:1 |
748a9306 |
708 | +12:+123:-1 |
5d7098d5 |
709 | -123:-123:0 |
748a9306 |
710 | -123:-12:-1 |
5d7098d5 |
711 | -12:-123:1 |
748a9306 |
712 | +123:+124:-1 |
5d7098d5 |
713 | +124:+123:1 |
714 | -123:-124:1 |
748a9306 |
715 | -124:-123:-1 |
5d7098d5 |
716 | +100:+5:1 |
58cde26e |
717 | -123456789:+987654321:-1 |
718 | +123456789:-987654321:1 |
719 | -987654321:+123456789:-1 |
0716bf9b |
720 | -inf:5432112345:-1 |
721 | +inf:5432112345:1 |
722 | -inf:-5432112345:-1 |
723 | +inf:-5432112345:1 |
724 | +inf:+inf:0 |
725 | -inf:-inf:0 |
726 | # return undef |
727 | +inf:NaN: |
728 | NaN:+inf: |
729 | -inf:NaN: |
730 | NaN:-inf: |
58cde26e |
731 | &binc |
732 | abc:NaN |
733 | +0:+1 |
734 | +1:+2 |
735 | -1:+0 |
736 | &bdec |
737 | abc:NaN |
738 | +0:-1 |
739 | +1:+0 |
740 | -1:-2 |
748a9306 |
741 | &badd |
742 | abc:abc:NaN |
743 | abc:+0:NaN |
744 | +0:abc:NaN |
745 | +0:+0:+0 |
746 | +1:+0:+1 |
747 | +0:+1:+1 |
748 | +1:+1:+2 |
749 | -1:+0:-1 |
750 | +0:-1:-1 |
751 | -1:-1:-2 |
752 | -1:+1:+0 |
753 | +1:-1:+0 |
754 | +9:+1:+10 |
755 | +99:+1:+100 |
756 | +999:+1:+1000 |
757 | +9999:+1:+10000 |
758 | +99999:+1:+100000 |
759 | +999999:+1:+1000000 |
760 | +9999999:+1:+10000000 |
761 | +99999999:+1:+100000000 |
762 | +999999999:+1:+1000000000 |
763 | +9999999999:+1:+10000000000 |
764 | +99999999999:+1:+100000000000 |
765 | +10:-1:+9 |
766 | +100:-1:+99 |
767 | +1000:-1:+999 |
768 | +10000:-1:+9999 |
769 | +100000:-1:+99999 |
770 | +1000000:-1:+999999 |
771 | +10000000:-1:+9999999 |
772 | +100000000:-1:+99999999 |
773 | +1000000000:-1:+999999999 |
774 | +10000000000:-1:+9999999999 |
775 | +123456789:+987654321:+1111111110 |
776 | -123456789:+987654321:+864197532 |
777 | -123456789:-987654321:-1111111110 |
778 | +123456789:-987654321:-864197532 |
779 | &bsub |
780 | abc:abc:NaN |
781 | abc:+0:NaN |
782 | +0:abc:NaN |
783 | +0:+0:+0 |
784 | +1:+0:+1 |
785 | +0:+1:-1 |
786 | +1:+1:+0 |
787 | -1:+0:-1 |
788 | +0:-1:+1 |
789 | -1:-1:+0 |
790 | -1:+1:-2 |
791 | +1:-1:+2 |
792 | +9:+1:+8 |
793 | +99:+1:+98 |
794 | +999:+1:+998 |
795 | +9999:+1:+9998 |
796 | +99999:+1:+99998 |
797 | +999999:+1:+999998 |
798 | +9999999:+1:+9999998 |
799 | +99999999:+1:+99999998 |
800 | +999999999:+1:+999999998 |
801 | +9999999999:+1:+9999999998 |
802 | +99999999999:+1:+99999999998 |
803 | +10:-1:+11 |
804 | +100:-1:+101 |
805 | +1000:-1:+1001 |
806 | +10000:-1:+10001 |
807 | +100000:-1:+100001 |
808 | +1000000:-1:+1000001 |
809 | +10000000:-1:+10000001 |
810 | +100000000:-1:+100000001 |
811 | +1000000000:-1:+1000000001 |
812 | +10000000000:-1:+10000000001 |
813 | +123456789:+987654321:-864197532 |
814 | -123456789:+987654321:-1111111110 |
815 | -123456789:-987654321:+864197532 |
816 | +123456789:-987654321:+1111111110 |
817 | &bmul |
818 | abc:abc:NaN |
819 | abc:+0:NaN |
820 | +0:abc:NaN |
821 | +0:+0:+0 |
822 | +0:+1:+0 |
823 | +1:+0:+0 |
824 | +0:-1:+0 |
825 | -1:+0:+0 |
826 | +123456789123456789:+0:+0 |
827 | +0:+123456789123456789:+0 |
828 | -1:-1:+1 |
829 | -1:+1:-1 |
830 | +1:-1:-1 |
831 | +1:+1:+1 |
832 | +2:+3:+6 |
833 | -2:+3:-6 |
834 | +2:-3:-6 |
835 | -2:-3:+6 |
836 | +111:+111:+12321 |
837 | +10101:+10101:+102030201 |
838 | +1001001:+1001001:+1002003002001 |
839 | +100010001:+100010001:+10002000300020001 |
840 | +10000100001:+10000100001:+100002000030000200001 |
841 | +11111111111:+9:+99999999999 |
842 | +22222222222:+9:+199999999998 |
843 | +33333333333:+9:+299999999997 |
844 | +44444444444:+9:+399999999996 |
845 | +55555555555:+9:+499999999995 |
846 | +66666666666:+9:+599999999994 |
847 | +77777777777:+9:+699999999993 |
848 | +88888888888:+9:+799999999992 |
849 | +99999999999:+9:+899999999991 |
58cde26e |
850 | +25:+25:+625 |
851 | +12345:+12345:+152399025 |
852 | +99999:+11111:+1111088889 |
748a9306 |
853 | &bdiv |
854 | abc:abc:NaN |
855 | abc:+1:abc:NaN |
0716bf9b |
856 | # really? |
857 | #+5:0:+inf |
858 | #-5:0:-inf |
748a9306 |
859 | +1:abc:NaN |
860 | +0:+0:NaN |
861 | +0:+1:+0 |
862 | +1:+0:NaN |
863 | +0:-1:+0 |
864 | -1:+0:NaN |
865 | +1:+1:+1 |
866 | -1:-1:+1 |
867 | +1:-1:-1 |
868 | -1:+1:-1 |
869 | +1:+2:+0 |
870 | +2:+1:+2 |
58cde26e |
871 | +1:+26:+0 |
748a9306 |
872 | +1000000000:+9:+111111111 |
873 | +2000000000:+9:+222222222 |
874 | +3000000000:+9:+333333333 |
875 | +4000000000:+9:+444444444 |
876 | +5000000000:+9:+555555555 |
877 | +6000000000:+9:+666666666 |
878 | +7000000000:+9:+777777777 |
879 | +8000000000:+9:+888888888 |
880 | +9000000000:+9:+1000000000 |
881 | +35500000:+113:+314159 |
882 | +71000000:+226:+314159 |
883 | +106500000:+339:+314159 |
884 | +1000000000:+3:+333333333 |
885 | +10:+5:+2 |
886 | +100:+4:+25 |
887 | +1000:+8:+125 |
888 | +10000:+16:+625 |
889 | +999999999999:+9:+111111111111 |
890 | +999999999999:+99:+10101010101 |
891 | +999999999999:+999:+1001001001 |
892 | +999999999999:+9999:+100010001 |
893 | +999999999999999:+99999:+10000100001 |
58cde26e |
894 | +1111088889:+99999:+11111 |
895 | -5:-3:1 |
896 | 4:3:1 |
897 | 1:3:0 |
898 | -2:-3:0 |
899 | -2:3:-1 |
900 | 1:-3:-1 |
901 | -5:3:-2 |
902 | 4:-3:-2 |
748a9306 |
903 | &bmod |
904 | abc:abc:NaN |
905 | abc:+1:abc:NaN |
906 | +1:abc:NaN |
907 | +0:+0:NaN |
908 | +0:+1:+0 |
909 | +1:+0:NaN |
910 | +0:-1:+0 |
911 | -1:+0:NaN |
912 | +1:+1:+0 |
913 | -1:-1:+0 |
914 | +1:-1:+0 |
915 | -1:+1:+0 |
916 | +1:+2:+1 |
917 | +2:+1:+0 |
918 | +1000000000:+9:+1 |
919 | +2000000000:+9:+2 |
920 | +3000000000:+9:+3 |
921 | +4000000000:+9:+4 |
922 | +5000000000:+9:+5 |
923 | +6000000000:+9:+6 |
924 | +7000000000:+9:+7 |
925 | +8000000000:+9:+8 |
926 | +9000000000:+9:+0 |
927 | +35500000:+113:+33 |
928 | +71000000:+226:+66 |
929 | +106500000:+339:+99 |
930 | +1000000000:+3:+1 |
931 | +10:+5:+0 |
932 | +100:+4:+0 |
933 | +1000:+8:+0 |
934 | +10000:+16:+0 |
935 | +999999999999:+9:+0 |
936 | +999999999999:+99:+0 |
937 | +999999999999:+999:+0 |
938 | +999999999999:+9999:+0 |
939 | +999999999999999:+99999:+0 |
58cde26e |
940 | -9:+5:+1 |
941 | +9:-5:-1 |
942 | -9:-5:-4 |
943 | -5:3:1 |
944 | -2:3:1 |
945 | 4:3:1 |
946 | 1:3:1 |
947 | -5:-3:-2 |
948 | -2:-3:-2 |
949 | 4:-3:-2 |
950 | 1:-3:-2 |
748a9306 |
951 | &bgcd |
952 | abc:abc:NaN |
953 | abc:+0:NaN |
954 | +0:abc:NaN |
955 | +0:+0:+0 |
956 | +0:+1:+1 |
957 | +1:+0:+1 |
958 | +1:+1:+1 |
959 | +2:+3:+1 |
960 | +3:+2:+1 |
58cde26e |
961 | -3:+2:+1 |
748a9306 |
962 | +100:+625:+25 |
963 | +4096:+81:+1 |
58cde26e |
964 | +1034:+804:+2 |
965 | +27:+90:+56:+1 |
966 | +27:+90:+54:+9 |
967 | &blcm |
e16b8f49 |
968 | abc:abc:NaN |
58cde26e |
969 | abc:+0:NaN |
970 | +0:abc:NaN |
971 | +0:+0:NaN |
972 | +1:+0:+0 |
973 | +0:+1:+0 |
974 | +27:+90:+270 |
975 | +1034:+804:+415668 |
e16b8f49 |
976 | &band |
977 | abc:abc:NaN |
58cde26e |
978 | abc:0:NaN |
979 | 0:abc:NaN |
0716bf9b |
980 | 1:2:0 |
981 | 3:2:2 |
e16b8f49 |
982 | +8:+2:+0 |
983 | +281474976710656:+0:+0 |
984 | +281474976710656:+1:+0 |
985 | +281474976710656:+281474976710656:+281474976710656 |
986 | &bior |
987 | abc:abc:NaN |
58cde26e |
988 | abc:0:NaN |
989 | 0:abc:NaN |
0716bf9b |
990 | 1:2:3 |
e16b8f49 |
991 | +8:+2:+10 |
992 | +281474976710656:+0:+281474976710656 |
993 | +281474976710656:+1:+281474976710657 |
994 | +281474976710656:+281474976710656:+281474976710656 |
995 | &bxor |
996 | abc:abc:NaN |
58cde26e |
997 | abc:0:NaN |
998 | 0:abc:NaN |
0716bf9b |
999 | 1:2:3 |
e16b8f49 |
1000 | +8:+2:+10 |
1001 | +281474976710656:+0:+281474976710656 |
1002 | +281474976710656:+1:+281474976710657 |
1003 | +281474976710656:+281474976710656:+0 |
1004 | &bnot |
1005 | abc:NaN |
1006 | +0:-1 |
1007 | +8:-9 |
1008 | +281474976710656:-281474976710657 |
58cde26e |
1009 | &digit |
1010 | 0:0:0 |
1011 | 12:0:2 |
1012 | 12:1:1 |
1013 | 123:0:3 |
1014 | 123:1:2 |
1015 | 123:2:1 |
1016 | 123:-1:1 |
1017 | 123:-2:2 |
1018 | 123:-3:3 |
1019 | 123456:0:6 |
1020 | 123456:1:5 |
1021 | 123456:2:4 |
1022 | 123456:3:3 |
1023 | 123456:4:2 |
1024 | 123456:5:1 |
1025 | 123456:-1:1 |
1026 | 123456:-2:2 |
1027 | 123456:-3:3 |
1028 | 100000:-3:0 |
1029 | 100000:0:0 |
1030 | 100000:1:0 |
1031 | &mantissa |
1032 | abc:NaN |
1033 | 1e4:1 |
1034 | 2e0:2 |
1035 | 123:123 |
1036 | -1:-1 |
1037 | -2:-2 |
1038 | &exponent |
1039 | abc:NaN |
1040 | 1e4:4 |
1041 | 2e0:0 |
1042 | 123:0 |
1043 | -1:0 |
1044 | -2:0 |
1045 | 0:1 |
1046 | &parts |
1047 | abc:NaN,NaN |
1048 | 1e4:1,4 |
1049 | 2e0:2,0 |
1050 | 123:123,0 |
1051 | -1:-1,0 |
1052 | -2:-2,0 |
1053 | 0:0,1 |
1054 | &bpow |
0716bf9b |
1055 | abc:12:NaN |
1056 | 12:abc:NaN |
58cde26e |
1057 | 0:0:1 |
1058 | 0:1:0 |
1059 | 0:2:0 |
1060 | 0:-1:NaN |
1061 | 0:-2:NaN |
1062 | 1:0:1 |
1063 | 1:1:1 |
1064 | 1:2:1 |
1065 | 1:3:1 |
1066 | 1:-1:1 |
1067 | 1:-2:1 |
1068 | 1:-3:1 |
1069 | 2:0:1 |
1070 | 2:1:2 |
1071 | 2:2:4 |
1072 | 2:3:8 |
1073 | 3:3:27 |
1074 | 2:-1:NaN |
1075 | -2:-1:NaN |
1076 | 2:-2:NaN |
1077 | -2:-2:NaN |
0716bf9b |
1078 | +inf:1234500012:+inf |
1079 | -inf:1234500012:-inf |
1080 | +inf:-12345000123:+inf |
1081 | -inf:-12345000123:-inf |
58cde26e |
1082 | # 1 ** -x => 1 / (1 ** x) |
1083 | -1:0:1 |
1084 | -2:0:1 |
1085 | -1:1:-1 |
1086 | -1:2:1 |
1087 | -1:3:-1 |
1088 | -1:4:1 |
1089 | -1:5:-1 |
1090 | -1:-1:-1 |
1091 | -1:-2:1 |
1092 | -1:-3:-1 |
1093 | -1:-4:1 |
1094 | 10:2:100 |
1095 | 10:3:1000 |
1096 | 10:4:10000 |
1097 | 10:5:100000 |
1098 | 10:6:1000000 |
1099 | 10:7:10000000 |
1100 | 10:8:100000000 |
1101 | 10:9:1000000000 |
1102 | 10:20:100000000000000000000 |
1103 | 123456:2:15241383936 |
1104 | &length |
1105 | 100:3 |
1106 | 10:2 |
1107 | 1:1 |
1108 | 0:1 |
1109 | 12345:5 |
1110 | 10000000000000000:17 |
1111 | -123:3 |
1112 | &bsqrt |
1113 | 144:12 |
1114 | 16:4 |
1115 | 4:2 |
1116 | 2:1 |
1117 | 12:3 |
1118 | 256:16 |
1119 | 100000000:10000 |
1120 | 4000000000000:2000000 |
1121 | 1:1 |
1122 | 0:0 |
1123 | -2:NaN |
1124 | Nan:NaN |
1125 | &bround |
1126 | $round_mode('trunc') |
1127 | 1234:0:1234 |
1128 | 1234:2:1200 |
1129 | 123456:4:123400 |
1130 | 123456:5:123450 |
1131 | 123456:6:123456 |
1132 | +10123456789:5:+10123000000 |
1133 | -10123456789:5:-10123000000 |
1134 | +10123456789:9:+10123456700 |
1135 | -10123456789:9:-10123456700 |
1136 | +101234500:6:+101234000 |
1137 | -101234500:6:-101234000 |
1138 | #+101234500:-4:+101234000 |
1139 | #-101234500:-4:-101234000 |
1140 | $round_mode('zero') |
1141 | +20123456789:5:+20123000000 |
1142 | -20123456789:5:-20123000000 |
1143 | +20123456789:9:+20123456800 |
1144 | -20123456789:9:-20123456800 |
1145 | +201234500:6:+201234000 |
1146 | -201234500:6:-201234000 |
1147 | #+201234500:-4:+201234000 |
1148 | #-201234500:-4:-201234000 |
1149 | +12345000:4:12340000 |
1150 | -12345000:4:-12340000 |
1151 | $round_mode('+inf') |
1152 | +30123456789:5:+30123000000 |
1153 | -30123456789:5:-30123000000 |
1154 | +30123456789:9:+30123456800 |
1155 | -30123456789:9:-30123456800 |
1156 | +301234500:6:+301235000 |
1157 | -301234500:6:-301234000 |
1158 | #+301234500:-4:+301235000 |
1159 | #-301234500:-4:-301234000 |
1160 | +12345000:4:12350000 |
1161 | -12345000:4:-12340000 |
1162 | $round_mode('-inf') |
1163 | +40123456789:5:+40123000000 |
1164 | -40123456789:5:-40123000000 |
1165 | +40123456789:9:+40123456800 |
1166 | -40123456789:9:-40123456800 |
1167 | +401234500:6:+401234000 |
1168 | +401234500:6:+401234000 |
1169 | #-401234500:-4:-401235000 |
1170 | #-401234500:-4:-401235000 |
1171 | +12345000:4:12340000 |
1172 | -12345000:4:-12350000 |
1173 | $round_mode('odd') |
1174 | +50123456789:5:+50123000000 |
1175 | -50123456789:5:-50123000000 |
1176 | +50123456789:9:+50123456800 |
1177 | -50123456789:9:-50123456800 |
1178 | +501234500:6:+501235000 |
1179 | -501234500:6:-501235000 |
1180 | #+501234500:-4:+501235000 |
1181 | #-501234500:-4:-501235000 |
1182 | +12345000:4:12350000 |
1183 | -12345000:4:-12350000 |
1184 | $round_mode('even') |
1185 | +60123456789:5:+60123000000 |
1186 | -60123456789:5:-60123000000 |
1187 | +60123456789:9:+60123456800 |
1188 | -60123456789:9:-60123456800 |
1189 | +601234500:6:+601234000 |
1190 | -601234500:6:-601234000 |
1191 | #+601234500:-4:+601234000 |
1192 | #-601234500:-4:-601234000 |
1193 | #-601234500:-9:0 |
1194 | #-501234500:-9:0 |
1195 | #-601234500:-8:0 |
1196 | #-501234500:-8:0 |
1197 | +1234567:7:1234567 |
1198 | +1234567:6:1234570 |
1199 | +12345000:4:12340000 |
1200 | -12345000:4:-12340000 |
58cde26e |
1201 | &is_zero |
1202 | 0:1 |
1203 | NaNzero:0 |
1204 | 123:0 |
1205 | -1:0 |
1206 | 1:0 |
58cde26e |
1207 | &is_one |
1208 | 0:0 |
1209 | 1:1 |
1210 | 2:0 |
1211 | -1:0 |
1212 | -2:0 |
1213 | # floor and ceil tests are pretty pointless in integer space...but play safe |
1214 | &bfloor |
1215 | 0:0 |
f216259d |
1216 | -1:-1 |
58cde26e |
1217 | -2:-2 |
1218 | 2:2 |
1219 | 3:3 |
1220 | abc:NaN |
1221 | &bceil |
1222 | 0:0 |
1223 | -1:-1 |
1224 | -2:-2 |
1225 | 2:2 |
1226 | 3:3 |
1227 | abc:NaN |