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