Commit | Line | Data |
184f15d5 |
1 | #include this file into another test for subclass testing... |
2 | |
3 | ok ($class->config()->{lib},$CL); |
4 | |
9b924220 |
5 | use strict; |
6 | |
184f15d5 |
7 | while (<DATA>) |
8 | { |
a4e2b1c6 |
9 | chomp; |
184f15d5 |
10 | $_ =~ s/#.*$//; # remove comments |
11 | $_ =~ s/\s+$//; # trailing spaces |
12 | next if /^$/; # skip empty lines & comments |
13 | if (s/^&//) |
14 | { |
15 | $f = $_; |
16 | } |
17 | elsif (/^\$/) |
18 | { |
19 | $setup = $_; $setup =~ s/\$/\$${class}::/g; # round_mode, div_scale |
20 | #print "\$setup== $setup\n"; |
21 | } |
22 | else |
23 | { |
24 | if (m|^(.*?):(/.+)$|) |
25 | { |
26 | $ans = $2; |
27 | @args = split(/:/,$1,99); |
28 | } |
29 | else |
30 | { |
31 | @args = split(/:/,$_,99); $ans = pop(@args); |
32 | } |
9b924220 |
33 | $try = "\$x = $class->new('$args[0]');"; |
184f15d5 |
34 | if ($f eq "fnorm") |
35 | { |
36 | $try .= "\$x;"; |
37 | } elsif ($f eq "finf") { |
9b924220 |
38 | $try .= "\$x->finf('$args[1]');"; |
184f15d5 |
39 | } elsif ($f eq "is_inf") { |
40 | $try .= "\$x->is_inf('$args[1]');"; |
41 | } elsif ($f eq "fone") { |
42 | $try .= "\$x->bone('$args[1]');"; |
43 | } elsif ($f eq "fstr") { |
44 | $try .= "\$x->accuracy($args[1]); \$x->precision($args[2]);"; |
9b924220 |
45 | $try .= '$x->fstr();'; |
184f15d5 |
46 | } elsif ($f eq "parts") { |
47 | # ->bstr() to see if an object is returned |
48 | $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();'; |
49 | $try .= '"$a $b";'; |
50 | } elsif ($f eq "exponent") { |
51 | # ->bstr() to see if an object is returned |
52 | $try .= '$x->exponent()->bstr();'; |
53 | } elsif ($f eq "mantissa") { |
54 | # ->bstr() to see if an object is returned |
55 | $try .= '$x->mantissa()->bstr();'; |
9b924220 |
56 | } elsif ($f =~ /^(numify|length|as_number|as_hex|as_bin)$/) { |
57 | $try .= "\$x->$f();"; |
184f15d5 |
58 | # some unary ops (test the fxxx form, since that is done by AUTOLOAD) |
59 | } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|abs)$/) { |
9b924220 |
60 | $try .= "\$x->f$1();"; |
184f15d5 |
61 | # some is_xxx test function |
62 | } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan|int)$/) { |
63 | $try .= "\$x->$f();"; |
184f15d5 |
64 | } elsif ($f eq "finc") { |
65 | $try .= '++$x;'; |
66 | } elsif ($f eq "fdec") { |
67 | $try .= '--$x;'; |
68 | }elsif ($f eq "fround") { |
9b924220 |
69 | $try .= "$setup; \$x->fround($args[1]);"; |
184f15d5 |
70 | } elsif ($f eq "ffround") { |
9b924220 |
71 | $try .= "$setup; \$x->ffround($args[1]);"; |
184f15d5 |
72 | } elsif ($f eq "fsqrt") { |
9b924220 |
73 | $try .= "$setup; \$x->fsqrt();"; |
184f15d5 |
74 | } elsif ($f eq "ffac") { |
9b924220 |
75 | $try .= "$setup; \$x->ffac();"; |
76 | } elsif ($f eq "flog") { |
77 | if ($args[1] ne '') |
78 | { |
79 | $try .= "\$y = $class->new($args[1]);"; |
80 | $try .= "$setup; \$x->flog(\$y);"; |
81 | } |
82 | else |
83 | { |
84 | $try .= "$setup; \$x->flog();"; |
85 | } |
184f15d5 |
86 | } |
87 | else |
88 | { |
9b924220 |
89 | $try .= "\$y = $class->new(\"$args[1]\");"; |
184f15d5 |
90 | if ($f eq "fcmp") { |
91 | $try .= '$x <=> $y;'; |
92 | } elsif ($f eq "facmp") { |
9b924220 |
93 | $try .= '$x->facmp($y);'; |
184f15d5 |
94 | } elsif ($f eq "fpow") { |
95 | $try .= '$x ** $y;'; |
9b924220 |
96 | } elsif ($f eq "froot") { |
97 | $try .= "$setup; \$x->froot(\$y);"; |
184f15d5 |
98 | } elsif ($f eq "fadd") { |
99 | $try .= '$x + $y;'; |
100 | } elsif ($f eq "fsub") { |
101 | $try .= '$x - $y;'; |
102 | } elsif ($f eq "fmul") { |
103 | $try .= '$x * $y;'; |
104 | } elsif ($f eq "fdiv") { |
105 | $try .= "$setup; \$x / \$y;"; |
106 | } elsif ($f eq "fdiv-list") { |
9b924220 |
107 | $try .= "$setup; join(',',\$x->fdiv(\$y));"; |
184f15d5 |
108 | } elsif ($f eq "frsft") { |
109 | $try .= '$x >> $y;'; |
110 | } elsif ($f eq "flsft") { |
111 | $try .= '$x << $y;'; |
112 | } elsif ($f eq "fmod") { |
113 | $try .= '$x % $y;'; |
114 | } else { warn "Unknown op '$f'"; } |
115 | } |
9b924220 |
116 | print "# Trying: '$try'\n"; |
184f15d5 |
117 | $ans1 = eval $try; |
118 | if ($ans =~ m|^/(.*)$|) |
119 | { |
120 | my $pat = $1; |
121 | if ($ans1 =~ /$pat/) |
122 | { |
123 | ok (1,1); |
124 | } |
125 | else |
126 | { |
127 | print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0); |
128 | } |
129 | } |
130 | else |
131 | { |
132 | if ($ans eq "") |
133 | { |
134 | ok_undef ($ans1); |
135 | } |
136 | else |
137 | { |
138 | print "# Tried: '$try'\n" if !ok ($ans1, $ans); |
9b924220 |
139 | if (ref($ans1) eq "$class") |
140 | { |
141 | # float numbers are normalized (for now), so mantissa shouldn't have |
142 | # trailing zeros |
143 | #print $ans1->_trailing_zeros(),"\n"; |
144 | print "# Has trailing zeros after '$try'\n" |
145 | if ref($ans) eq 'HASH' && exists $ans->{_m} && !ok ($ans1->{_m}->_trailing_zeros(), 0); |
146 | } |
184f15d5 |
147 | } |
148 | } # end pattern or string |
149 | } |
150 | } # end while |
151 | |
152 | # check whether $class->new( Math::BigInt->new()) destroys it |
153 | # ($y == 12 in this case) |
154 | $x = Math::BigInt->new(1200); $y = $class->new($x); |
155 | ok ($y,1200); ok ($x,1200); |
156 | |
157 | ############################################################################### |
9b924220 |
158 | # Really huge, big, ultra-mega-biggy-monster exponents |
159 | # Technically, the exponents should not be limited (they are BigInts), but |
160 | # practically there are a few places were they are limited to a Perl scalar. |
161 | # This is sometimes for speed, sometimes because otherwise the number wouldn't |
162 | # fit into your memory (just think of 1e123456789012345678901234567890 + 1!) |
163 | # anyway. We don't test everything here, but let's make sure it just basically |
164 | # works. |
165 | |
166 | # |
167 | #my $monster = '1e1234567890123456789012345678901234567890'; |
168 | # |
169 | ## new |
170 | #ok ($class->new($monster)->bsstr(), |
171 | # '1e+1234567890123456789012345678901234567890'); |
172 | ## cmp |
173 | #ok ($class->new($monster) > 0,1); |
174 | # |
175 | ## sub/mul |
176 | #ok ($class->new($monster)->bsub( $monster),0); |
177 | #ok ($class->new($monster)->bmul(2)->bsstr(), |
178 | # '2e+1234567890123456789012345678901234567890'); |
179 | |
180 | ############################################################################### |
184f15d5 |
181 | # zero,inf,one,nan |
182 | |
183 | $x = $class->new(2); $x->fzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
184 | $x = $class->new(2); $x->finf(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
185 | $x = $class->new(2); $x->fone(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
186 | $x = $class->new(2); $x->fnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p}); |
9b924220 |
187 | |
188 | ############################################################################### |
189 | # bone/binf etc as plain calls (Lite failed them) |
190 | |
191 | ok ($class->fzero(),0); |
192 | ok ($class->fone(),1); |
193 | ok ($class->fone('+'),1); |
194 | ok ($class->fone('-'),-1); |
195 | ok ($class->fnan(),'NaN'); |
196 | ok ($class->finf(),'inf'); |
197 | ok ($class->finf('+'),'inf'); |
198 | ok ($class->finf('-'),'-inf'); |
199 | ok ($class->finf('-inf'),'-inf'); |
184f15d5 |
200 | |
9b924220 |
201 | $class->accuracy(undef); $class->precision(undef); # reset |
202 | |
203 | ############################################################################### |
204 | # bug in bsstr()/numify() showed up in after-rounding in bdiv() |
205 | |
206 | $x = $class->new('0.008'); $y = $class->new(2); |
207 | $x->bdiv(3,$y); |
208 | ok ($x,'0.0027'); |
209 | |
184f15d5 |
210 | ############################################################################### |
211 | # fsqrt() with set global A/P or A/P enabled on $x, also a test whether fsqrt() |
212 | # correctly modifies $x |
213 | |
184f15d5 |
214 | |
215 | $x = $class->new(12); $class->precision(-2); $x->fsqrt(); ok ($x,'3.46'); |
216 | |
217 | $class->precision(undef); |
218 | $x = $class->new(12); $class->precision(0); $x->fsqrt(); ok ($x,'3'); |
219 | |
220 | $class->precision(-3); $x = $class->new(12); $x->fsqrt(); ok ($x,'3.464'); |
221 | |
9b924220 |
222 | { |
223 | no strict 'refs'; |
224 | # A and P set => NaN |
225 | ${${class}.'::accuracy'} = 4; $x = $class->new(12); |
226 | $x->fsqrt(3); ok ($x,'NaN'); |
227 | # supplied arg overrides set global |
228 | $class->precision(undef); $x = $class->new(12); $x->fsqrt(3); ok ($x,'3.46'); |
229 | $class->accuracy(undef); $class->precision(undef); # reset for further tests |
230 | } |
231 | |
232 | ############################################################################# |
233 | # can we call objectify (broken until v1.52) |
234 | |
235 | { |
236 | no strict; |
237 | $try = |
238 | '@args' . " = $class" . "::objectify(2,$class,4,5);".'join(" ",@args);'; |
239 | $ans = eval $try; |
240 | ok ($ans,"$class 4 5"); |
241 | } |
184f15d5 |
242 | |
9b924220 |
243 | ############################################################################# |
244 | # is_one('-') (broken until v1.64) |
245 | |
246 | ok ($class->new(-1)->is_one(),0); |
247 | ok ($class->new(-1)->is_one('-'),1); |
184f15d5 |
248 | |
249 | 1; # all done |
250 | |
251 | ############################################################################### |
252 | # Perl 5.005 does not like ok ($x,undef) |
253 | |
254 | sub ok_undef |
255 | { |
256 | my $x = shift; |
257 | |
258 | ok (1,1) and return if !defined $x; |
259 | ok ($x,'undef'); |
260 | } |
261 | |
262 | __DATA__ |
263 | $div_scale = 40; |
264 | &flog |
9b924220 |
265 | 0::NaN |
266 | -1::NaN |
267 | -2::NaN |
268 | # base > 0, base != 1 |
269 | 2:-1:NaN |
270 | 2:0:NaN |
271 | 2:1:NaN |
272 | # log(1) is always 1, regardless of $base |
273 | 1::0 |
274 | 1:1:0 |
275 | 1:2:0 |
184f15d5 |
276 | # this is too slow for the testsuite |
9b924220 |
277 | #2:0.6931471805599453094172321214581765680755 |
184f15d5 |
278 | #2.718281828:0.9999999998311266953289851340574956564911 |
279 | #$div_scale = 20; |
280 | #2.718281828:0.99999999983112669533 |
9b924220 |
281 | # too slow, too |
184f15d5 |
282 | #123:4.8112184355 |
9b924220 |
283 | $div_scale = 14; |
184f15d5 |
284 | #10:0:2.302585092994 |
285 | #1000:0:6.90775527898214 |
286 | #100:0:4.60517018598809 |
9b924220 |
287 | 2::0.69314718055995 |
184f15d5 |
288 | #3.1415:0:1.14470039286086 |
9b924220 |
289 | # too slow |
184f15d5 |
290 | #12345:0:9.42100640177928 |
291 | #0.001:0:-6.90775527898214 |
292 | # reset for further tests |
293 | $div_scale = 40; |
9b924220 |
294 | 1::0 |
184f15d5 |
295 | &frsft |
296 | NaNfrsft:2:NaN |
297 | 0:2:0 |
298 | 1:1:0.5 |
299 | 2:1:1 |
300 | 4:1:2 |
301 | 123:1:61.5 |
302 | 32:3:4 |
303 | &flsft |
304 | NaNflsft:0:NaN |
305 | 2:1:4 |
306 | 4:3:32 |
307 | 5:3:40 |
308 | 1:2:4 |
309 | 0:5:0 |
310 | &fnorm |
311 | 1:1 |
312 | -0:0 |
313 | fnormNaN:NaN |
314 | +inf:inf |
315 | -inf:-inf |
316 | 123:123 |
317 | -123.4567:-123.4567 |
318 | # invalid inputs |
319 | 1__2:NaN |
320 | 1E1__2:NaN |
321 | 11__2E2:NaN |
322 | #1.E3:NaN |
323 | .2E-3.:NaN |
324 | #1e3e4:NaN |
325 | .2E2:20 |
326 | &as_number |
327 | 0:0 |
328 | 1:1 |
329 | 1.2:1 |
330 | 2.345:2 |
331 | -2:-2 |
332 | -123.456:-123 |
333 | -200:-200 |
9b924220 |
334 | # test for bug in brsft() not handling cases that return 0 |
335 | 0.000641:0 |
336 | 0.0006412:0 |
337 | 0.00064123:0 |
338 | 0.000641234:0 |
339 | 0.0006412345:0 |
340 | 0.00064123456:0 |
341 | 0.000641234567:0 |
342 | 0.0006412345678:0 |
343 | 0.00064123456789:0 |
344 | 0.1:0 |
345 | 0.01:0 |
346 | 0.001:0 |
347 | 0.0001:0 |
348 | 0.00001:0 |
349 | 0.000001:0 |
350 | 0.0000001:0 |
351 | 0.00000001:0 |
352 | 0.000000001:0 |
353 | 0.0000000001:0 |
354 | 0.00000000001:0 |
355 | 0.12345:0 |
356 | 0.123456:0 |
357 | 0.1234567:0 |
358 | 0.12345678:0 |
359 | 0.123456789:0 |
184f15d5 |
360 | &finf |
361 | 1:+:inf |
362 | 2:-:-inf |
363 | 3:abc:inf |
9b924220 |
364 | &as_hex |
365 | +inf:inf |
366 | -inf:-inf |
367 | hexNaN:NaN |
368 | 0:0x0 |
369 | 5:0x5 |
370 | -5:-0x5 |
371 | &as_bin |
372 | +inf:inf |
373 | -inf:-inf |
374 | hexNaN:NaN |
375 | 0:0b0 |
376 | 5:0b101 |
377 | -5:-0b101 |
184f15d5 |
378 | &numify |
9b924220 |
379 | # uses bsstr() so 5 => 5e+0 to be compatible w/ Perls output |
184f15d5 |
380 | 0:0e+1 |
381 | +1:1e+0 |
382 | 1234:1234e+0 |
383 | NaN:NaN |
384 | +inf:inf |
385 | -inf:-inf |
9b924220 |
386 | -5:-5e+0 |
387 | 100:1e+2 |
388 | -100:-1e+2 |
184f15d5 |
389 | &fnan |
390 | abc:NaN |
391 | 2:NaN |
392 | -2:NaN |
393 | 0:NaN |
394 | &fone |
395 | 2:+:1 |
396 | -2:-:-1 |
397 | -2:+:1 |
398 | 2:-:-1 |
399 | 0::1 |
400 | -2::1 |
401 | abc::1 |
402 | 2:abc:1 |
403 | &fsstr |
404 | +inf:inf |
405 | -inf:-inf |
406 | abcfsstr:NaN |
9b924220 |
407 | -abcfsstr:NaN |
184f15d5 |
408 | 1234.567:1234567e-3 |
9b924220 |
409 | 123:123e+0 |
410 | -5:-5e+0 |
411 | -100:-1e+2 |
184f15d5 |
412 | &fstr |
413 | +inf:::inf |
414 | -inf:::-inf |
415 | abcfstr:::NaN |
416 | 1234.567:9::1234.56700 |
417 | 1234.567::-6:1234.567000 |
418 | 12345:5::12345 |
419 | 0.001234:6::0.00123400 |
420 | 0.001234::-8:0.00123400 |
421 | 0:4::0 |
422 | 0::-4:0.0000 |
423 | &fnorm |
424 | inf:inf |
425 | +inf:inf |
426 | -inf:-inf |
427 | +infinity:NaN |
428 | +-inf:NaN |
429 | abc:NaN |
430 | 1 a:NaN |
431 | 1bcd2:NaN |
432 | 11111b:NaN |
433 | +1z:NaN |
434 | -1z:NaN |
9b924220 |
435 | 0e999:0 |
436 | 0e-999:0 |
437 | -0e999:0 |
438 | -0e-999:0 |
184f15d5 |
439 | 0:0 |
440 | +0:0 |
441 | +00:0 |
442 | +0_0_0:0 |
443 | 000000_0000000_00000:0 |
444 | -0:0 |
445 | -0000:0 |
446 | +1:1 |
447 | +01:1 |
448 | +001:1 |
449 | +00000100000:100000 |
450 | 123456789:123456789 |
451 | -1:-1 |
452 | -01:-1 |
453 | -001:-1 |
454 | -123456789:-123456789 |
455 | -00000100000:-100000 |
456 | 123.456a:NaN |
457 | 123.456:123.456 |
458 | 0.01:0.01 |
459 | .002:0.002 |
460 | +.2:0.2 |
461 | -0.0003:-0.0003 |
462 | -.0000000004:-0.0000000004 |
463 | 123456E2:12345600 |
464 | 123456E-2:1234.56 |
465 | -123456E2:-12345600 |
466 | -123456E-2:-1234.56 |
467 | 1e1:10 |
468 | 2e-11:0.00000000002 |
469 | # excercise _split |
470 | .02e-1:0.002 |
471 | 000001:1 |
472 | -00001:-1 |
473 | -1:-1 |
474 | 000.01:0.01 |
475 | -000.0023:-0.0023 |
476 | 1.1e1:11 |
477 | -3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
478 | -4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004 |
479 | &fpow |
480 | 2:2:4 |
481 | 1:2:1 |
482 | 1:3:1 |
483 | -1:2:1 |
484 | -1:3:-1 |
485 | 123.456:2:15241.383936 |
486 | 2:-2:0.25 |
487 | 2:-3:0.125 |
488 | 128:-2:0.00006103515625 |
489 | abc:123.456:NaN |
490 | 123.456:abc:NaN |
491 | +inf:123.45:inf |
492 | -inf:123.45:-inf |
493 | +inf:-123.45:inf |
494 | -inf:-123.45:-inf |
9b924220 |
495 | # 2 ** 0.5 == sqrt(2) |
496 | # 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0) |
497 | 2:0.5:1.41421356237309504880168872420969807857 |
498 | #2:0.2:1.148698354997035006798626946777927589444 |
499 | #6:1.5:14.6969384566990685891837044482353483518 |
500 | $div_scale = 20; |
501 | #62.5:12.5:26447206647554886213592.3959144 |
502 | $div_scale = 40; |
184f15d5 |
503 | &fneg |
504 | fnegNaN:NaN |
505 | +inf:-inf |
506 | -inf:inf |
507 | +0:0 |
508 | +1:-1 |
509 | -1:1 |
510 | +123456789:-123456789 |
511 | -123456789:123456789 |
512 | +123.456789:-123.456789 |
513 | -123456.789:123456.789 |
514 | &fabs |
515 | fabsNaN:NaN |
516 | +inf:inf |
517 | -inf:inf |
518 | +0:0 |
519 | +1:1 |
520 | -1:1 |
521 | +123456789:123456789 |
522 | -123456789:123456789 |
523 | +123.456789:123.456789 |
524 | -123456.789:123456.789 |
525 | &fround |
526 | $round_mode = "trunc" |
527 | +inf:5:inf |
528 | -inf:5:-inf |
529 | 0:5:0 |
530 | NaNfround:5:NaN |
531 | +10123456789:5:10123000000 |
532 | -10123456789:5:-10123000000 |
533 | +10123456789.123:5:10123000000 |
534 | -10123456789.123:5:-10123000000 |
535 | +10123456789:9:10123456700 |
536 | -10123456789:9:-10123456700 |
537 | +101234500:6:101234000 |
538 | -101234500:6:-101234000 |
539 | $round_mode = "zero" |
540 | +20123456789:5:20123000000 |
541 | -20123456789:5:-20123000000 |
542 | +20123456789.123:5:20123000000 |
543 | -20123456789.123:5:-20123000000 |
544 | +20123456789:9:20123456800 |
545 | -20123456789:9:-20123456800 |
546 | +201234500:6:201234000 |
547 | -201234500:6:-201234000 |
548 | $round_mode = "+inf" |
549 | +30123456789:5:30123000000 |
550 | -30123456789:5:-30123000000 |
551 | +30123456789.123:5:30123000000 |
552 | -30123456789.123:5:-30123000000 |
553 | +30123456789:9:30123456800 |
554 | -30123456789:9:-30123456800 |
555 | +301234500:6:301235000 |
556 | -301234500:6:-301234000 |
557 | $round_mode = "-inf" |
558 | +40123456789:5:40123000000 |
559 | -40123456789:5:-40123000000 |
560 | +40123456789.123:5:40123000000 |
561 | -40123456789.123:5:-40123000000 |
562 | +40123456789:9:40123456800 |
563 | -40123456789:9:-40123456800 |
564 | +401234500:6:401234000 |
565 | -401234500:6:-401235000 |
566 | $round_mode = "odd" |
567 | +50123456789:5:50123000000 |
568 | -50123456789:5:-50123000000 |
569 | +50123456789.123:5:50123000000 |
570 | -50123456789.123:5:-50123000000 |
571 | +50123456789:9:50123456800 |
572 | -50123456789:9:-50123456800 |
573 | +501234500:6:501235000 |
574 | -501234500:6:-501235000 |
575 | $round_mode = "even" |
576 | +60123456789:5:60123000000 |
577 | -60123456789:5:-60123000000 |
578 | +60123456789:9:60123456800 |
579 | -60123456789:9:-60123456800 |
580 | +601234500:6:601234000 |
581 | -601234500:6:-601234000 |
582 | +60123456789.0123:5:60123000000 |
583 | -60123456789.0123:5:-60123000000 |
584 | &ffround |
585 | $round_mode = "trunc" |
586 | +inf:5:inf |
587 | -inf:5:-inf |
588 | 0:5:0 |
589 | NaNffround:5:NaN |
590 | +1.23:-1:1.2 |
591 | +1.234:-1:1.2 |
592 | +1.2345:-1:1.2 |
593 | +1.23:-2:1.23 |
594 | +1.234:-2:1.23 |
595 | +1.2345:-2:1.23 |
596 | +1.23:-3:1.230 |
597 | +1.234:-3:1.234 |
598 | +1.2345:-3:1.234 |
599 | -1.23:-1:-1.2 |
600 | +1.27:-1:1.2 |
601 | -1.27:-1:-1.2 |
602 | +1.25:-1:1.2 |
603 | -1.25:-1:-1.2 |
604 | +1.35:-1:1.3 |
605 | -1.35:-1:-1.3 |
606 | -0.0061234567890:-1:0.0 |
607 | -0.0061:-1:0.0 |
608 | -0.00612:-1:0.0 |
609 | -0.00612:-2:0.00 |
610 | -0.006:-1:0.0 |
611 | -0.006:-2:0.00 |
612 | -0.0006:-2:0.00 |
613 | -0.0006:-3:0.000 |
614 | -0.0065:-3:/-0\.006|-6e-03 |
615 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
616 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
617 | 0.05:0:0 |
618 | 0.5:0:0 |
619 | 0.51:0:0 |
620 | 0.41:0:0 |
621 | $round_mode = "zero" |
622 | +2.23:-1:/2.2(?:0{5}\d+)? |
623 | -2.23:-1:/-2.2(?:0{5}\d+)? |
624 | +2.27:-1:/2.(?:3|29{5}\d+) |
625 | -2.27:-1:/-2.(?:3|29{5}\d+) |
626 | +2.25:-1:/2.2(?:0{5}\d+)? |
627 | -2.25:-1:/-2.2(?:0{5}\d+)? |
628 | +2.35:-1:/2.(?:3|29{5}\d+) |
629 | -2.35:-1:/-2.(?:3|29{5}\d+) |
630 | -0.0065:-1:0.0 |
631 | -0.0065:-2:/-0\.01|-1e-02 |
632 | -0.0065:-3:/-0\.006|-6e-03 |
633 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
634 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
635 | 0.05:0:0 |
636 | 0.5:0:0 |
637 | 0.51:0:1 |
638 | 0.41:0:0 |
639 | $round_mode = "+inf" |
640 | +3.23:-1:/3.2(?:0{5}\d+)? |
641 | -3.23:-1:/-3.2(?:0{5}\d+)? |
642 | +3.27:-1:/3.(?:3|29{5}\d+) |
643 | -3.27:-1:/-3.(?:3|29{5}\d+) |
644 | +3.25:-1:/3.(?:3|29{5}\d+) |
645 | -3.25:-1:/-3.2(?:0{5}\d+)? |
646 | +3.35:-1:/3.(?:4|39{5}\d+) |
647 | -3.35:-1:/-3.(?:3|29{5}\d+) |
648 | -0.0065:-1:0.0 |
649 | -0.0065:-2:/-0\.01|-1e-02 |
650 | -0.0065:-3:/-0\.006|-6e-03 |
651 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
652 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
653 | 0.05:0:0 |
654 | 0.5:0:1 |
655 | 0.51:0:1 |
656 | 0.41:0:0 |
657 | $round_mode = "-inf" |
658 | +4.23:-1:/4.2(?:0{5}\d+)? |
659 | -4.23:-1:/-4.2(?:0{5}\d+)? |
660 | +4.27:-1:/4.(?:3|29{5}\d+) |
661 | -4.27:-1:/-4.(?:3|29{5}\d+) |
662 | +4.25:-1:/4.2(?:0{5}\d+)? |
663 | -4.25:-1:/-4.(?:3|29{5}\d+) |
664 | +4.35:-1:/4.(?:3|29{5}\d+) |
665 | -4.35:-1:/-4.(?:4|39{5}\d+) |
666 | -0.0065:-1:0.0 |
667 | -0.0065:-2:/-0\.01|-1e-02 |
668 | -0.0065:-3:/-0\.007|-7e-03 |
669 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
670 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
671 | 0.05:0:0 |
672 | 0.5:0:0 |
673 | 0.51:0:1 |
674 | 0.41:0:0 |
675 | $round_mode = "odd" |
676 | +5.23:-1:/5.2(?:0{5}\d+)? |
677 | -5.23:-1:/-5.2(?:0{5}\d+)? |
678 | +5.27:-1:/5.(?:3|29{5}\d+) |
679 | -5.27:-1:/-5.(?:3|29{5}\d+) |
680 | +5.25:-1:/5.(?:3|29{5}\d+) |
681 | -5.25:-1:/-5.(?:3|29{5}\d+) |
682 | +5.35:-1:/5.(?:3|29{5}\d+) |
683 | -5.35:-1:/-5.(?:3|29{5}\d+) |
684 | -0.0065:-1:0.0 |
685 | -0.0065:-2:/-0\.01|-1e-02 |
686 | -0.0065:-3:/-0\.007|-7e-03 |
687 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
688 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
689 | 0.05:0:0 |
690 | 0.5:0:1 |
691 | 0.51:0:1 |
692 | 0.41:0:0 |
693 | $round_mode = "even" |
694 | +6.23:-1:/6.2(?:0{5}\d+)? |
695 | -6.23:-1:/-6.2(?:0{5}\d+)? |
696 | +6.27:-1:/6.(?:3|29{5}\d+) |
697 | -6.27:-1:/-6.(?:3|29{5}\d+) |
698 | +6.25:-1:/6.(?:2(?:0{5}\d+)?|29{5}\d+) |
699 | -6.25:-1:/-6.(?:2(?:0{5}\d+)?|29{5}\d+) |
700 | +6.35:-1:/6.(?:4|39{5}\d+|29{8}\d+) |
701 | -6.35:-1:/-6.(?:4|39{5}\d+|29{8}\d+) |
702 | -0.0065:-1:0.0 |
703 | -0.0065:-2:/-0\.01|-1e-02 |
704 | -0.0065:-3:/-0\.006|-7e-03 |
705 | -0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
706 | -0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03 |
707 | 0.05:0:0 |
708 | 0.5:0:0 |
709 | 0.51:0:1 |
710 | 0.41:0:0 |
711 | 0.01234567:-3:0.012 |
712 | 0.01234567:-4:0.0123 |
713 | 0.01234567:-5:0.01235 |
714 | 0.01234567:-6:0.012346 |
715 | 0.01234567:-7:0.0123457 |
716 | 0.01234567:-8:0.01234567 |
717 | 0.01234567:-9:0.012345670 |
718 | 0.01234567:-12:0.012345670000 |
719 | &fcmp |
720 | fcmpNaN:fcmpNaN: |
721 | fcmpNaN:+0: |
722 | +0:fcmpNaN: |
723 | +0:+0:0 |
724 | -1:+0:-1 |
725 | +0:-1:1 |
726 | +1:+0:1 |
727 | +0:+1:-1 |
728 | -1:+1:-1 |
729 | +1:-1:1 |
730 | -1:-1:0 |
731 | +1:+1:0 |
732 | -1.1:0:-1 |
733 | +0:-1.1:1 |
734 | +1.1:+0:1 |
735 | +0:+1.1:-1 |
736 | +123:+123:0 |
737 | +123:+12:1 |
738 | +12:+123:-1 |
739 | -123:-123:0 |
740 | -123:-12:-1 |
741 | -12:-123:1 |
742 | +123:+124:-1 |
743 | +124:+123:1 |
744 | -123:-124:1 |
745 | -124:-123:-1 |
746 | 0:0.01:-1 |
747 | 0:0.0001:-1 |
748 | 0:-0.0001:1 |
749 | 0:-0.1:1 |
750 | 0.1:0:1 |
751 | 0.00001:0:1 |
752 | -0.0001:0:-1 |
753 | -0.1:0:-1 |
754 | 0:0.0001234:-1 |
755 | 0:-0.0001234:1 |
756 | 0.0001234:0:1 |
757 | -0.0001234:0:-1 |
758 | 0.0001:0.0005:-1 |
759 | 0.0005:0.0001:1 |
760 | 0.005:0.0001:1 |
761 | 0.001:0.0005:1 |
762 | 0.000001:0.0005:-1 |
763 | 0.00000123:0.0005:-1 |
764 | 0.00512:0.0001:1 |
765 | 0.005:0.000112:1 |
766 | 0.00123:0.0005:1 |
767 | 1.5:2:-1 |
768 | 2:1.5:1 |
769 | 1.54321:234:-1 |
770 | 234:1.54321:1 |
771 | # infinity |
772 | -inf:5432112345:-1 |
773 | +inf:5432112345:1 |
774 | -inf:-5432112345:-1 |
775 | +inf:-5432112345:1 |
776 | -inf:54321.12345:-1 |
777 | +inf:54321.12345:1 |
778 | -inf:-54321.12345:-1 |
779 | +inf:-54321.12345:1 |
780 | +inf:+inf:0 |
781 | -inf:-inf:0 |
782 | +inf:-inf:1 |
783 | -inf:+inf:-1 |
784 | # return undef |
785 | +inf:NaN: |
786 | NaN:inf: |
787 | -inf:NaN: |
788 | NaN:-inf: |
789 | &facmp |
790 | fcmpNaN:fcmpNaN: |
791 | fcmpNaN:+0: |
792 | +0:fcmpNaN: |
793 | +0:+0:0 |
794 | -1:+0:1 |
795 | +0:-1:-1 |
796 | +1:+0:1 |
797 | +0:+1:-1 |
798 | -1:+1:0 |
799 | +1:-1:0 |
800 | -1:-1:0 |
801 | +1:+1:0 |
802 | -1.1:0:1 |
803 | +0:-1.1:-1 |
804 | +1.1:+0:1 |
805 | +0:+1.1:-1 |
806 | +123:+123:0 |
807 | +123:+12:1 |
808 | +12:+123:-1 |
809 | -123:-123:0 |
810 | -123:-12:1 |
811 | -12:-123:-1 |
812 | +123:+124:-1 |
813 | +124:+123:1 |
814 | -123:-124:-1 |
815 | -124:-123:1 |
816 | 0:0.01:-1 |
817 | 0:0.0001:-1 |
818 | 0:-0.0001:-1 |
819 | 0:-0.1:-1 |
820 | 0.1:0:1 |
821 | 0.00001:0:1 |
822 | -0.0001:0:1 |
823 | -0.1:0:1 |
824 | 0:0.0001234:-1 |
825 | 0:-0.0001234:-1 |
826 | 0.0001234:0:1 |
827 | -0.0001234:0:1 |
828 | 0.0001:0.0005:-1 |
829 | 0.0005:0.0001:1 |
830 | 0.005:0.0001:1 |
831 | 0.001:0.0005:1 |
832 | 0.000001:0.0005:-1 |
833 | 0.00000123:0.0005:-1 |
834 | 0.00512:0.0001:1 |
835 | 0.005:0.000112:1 |
836 | 0.00123:0.0005:1 |
837 | 1.5:2:-1 |
838 | 2:1.5:1 |
839 | 1.54321:234:-1 |
840 | 234:1.54321:1 |
841 | # infinity |
842 | -inf:5432112345:1 |
843 | +inf:5432112345:1 |
844 | -inf:-5432112345:1 |
845 | +inf:-5432112345:1 |
846 | -inf:54321.12345:1 |
847 | +inf:54321.12345:1 |
848 | -inf:-54321.12345:1 |
849 | +inf:-54321.12345:1 |
850 | +inf:+inf:0 |
851 | -inf:-inf:0 |
852 | +inf:-inf:0 |
853 | -inf:+inf:0 |
854 | 5:inf:-1 |
855 | -1:inf:-1 |
856 | 5:-inf:-1 |
857 | -1:-inf:-1 |
858 | # return undef |
859 | +inf:facmpNaN: |
860 | facmpNaN:inf: |
861 | -inf:facmpNaN: |
862 | facmpNaN:-inf: |
863 | &fdec |
864 | fdecNaN:NaN |
865 | +inf:inf |
866 | -inf:-inf |
867 | +0:-1 |
868 | +1:0 |
869 | -1:-2 |
870 | 1.23:0.23 |
871 | -1.23:-2.23 |
872 | 100:99 |
873 | 101:100 |
874 | -100:-101 |
875 | -99:-100 |
876 | -98:-99 |
877 | 99:98 |
878 | &finc |
879 | fincNaN:NaN |
880 | +inf:inf |
881 | -inf:-inf |
882 | +0:1 |
883 | +1:2 |
884 | -1:0 |
885 | 1.23:2.23 |
886 | -1.23:-0.23 |
887 | 100:101 |
888 | -100:-99 |
889 | -99:-98 |
890 | -101:-100 |
891 | 99:100 |
892 | &fadd |
893 | abc:abc:NaN |
894 | abc:+0:NaN |
895 | +0:abc:NaN |
9b924220 |
896 | +inf:-inf:NaN |
897 | -inf:+inf:NaN |
184f15d5 |
898 | +inf:+inf:inf |
899 | -inf:-inf:-inf |
900 | baddNaN:+inf:NaN |
901 | baddNaN:+inf:NaN |
902 | +inf:baddNaN:NaN |
903 | -inf:baddNaN:NaN |
904 | +0:+0:0 |
905 | +1:+0:1 |
906 | +0:+1:1 |
907 | +1:+1:2 |
908 | -1:+0:-1 |
909 | +0:-1:-1 |
910 | -1:-1:-2 |
911 | -1:+1:0 |
912 | +1:-1:0 |
913 | +9:+1:10 |
914 | +99:+1:100 |
915 | +999:+1:1000 |
916 | +9999:+1:10000 |
917 | +99999:+1:100000 |
918 | +999999:+1:1000000 |
919 | +9999999:+1:10000000 |
920 | +99999999:+1:100000000 |
921 | +999999999:+1:1000000000 |
922 | +9999999999:+1:10000000000 |
923 | +99999999999:+1:100000000000 |
924 | +10:-1:9 |
925 | +100:-1:99 |
926 | +1000:-1:999 |
927 | +10000:-1:9999 |
928 | +100000:-1:99999 |
929 | +1000000:-1:999999 |
930 | +10000000:-1:9999999 |
931 | +100000000:-1:99999999 |
932 | +1000000000:-1:999999999 |
933 | +10000000000:-1:9999999999 |
934 | +123456789:+987654321:1111111110 |
935 | -123456789:+987654321:864197532 |
936 | -123456789:-987654321:-1111111110 |
937 | +123456789:-987654321:-864197532 |
938 | 0.001234:0.0001234:0.0013574 |
939 | &fsub |
940 | abc:abc:NaN |
941 | abc:+0:NaN |
942 | +0:abc:NaN |
943 | +inf:-inf:inf |
944 | -inf:+inf:-inf |
9b924220 |
945 | +inf:+inf:NaN |
946 | -inf:-inf:NaN |
184f15d5 |
947 | baddNaN:+inf:NaN |
948 | baddNaN:+inf:NaN |
949 | +inf:baddNaN:NaN |
950 | -inf:baddNaN:NaN |
951 | +0:+0:0 |
952 | +1:+0:1 |
953 | +0:+1:-1 |
954 | +1:+1:0 |
955 | -1:+0:-1 |
956 | +0:-1:1 |
957 | -1:-1:0 |
958 | -1:+1:-2 |
959 | +1:-1:2 |
960 | +9:+1:8 |
961 | +99:+1:98 |
962 | +999:+1:998 |
963 | +9999:+1:9998 |
964 | +99999:+1:99998 |
965 | +999999:+1:999998 |
966 | +9999999:+1:9999998 |
967 | +99999999:+1:99999998 |
968 | +999999999:+1:999999998 |
969 | +9999999999:+1:9999999998 |
970 | +99999999999:+1:99999999998 |
971 | +10:-1:11 |
972 | +100:-1:101 |
973 | +1000:-1:1001 |
974 | +10000:-1:10001 |
975 | +100000:-1:100001 |
976 | +1000000:-1:1000001 |
977 | +10000000:-1:10000001 |
978 | +100000000:-1:100000001 |
979 | +1000000000:-1:1000000001 |
980 | +10000000000:-1:10000000001 |
981 | +123456789:+987654321:-864197532 |
982 | -123456789:+987654321:-1111111110 |
983 | -123456789:-987654321:864197532 |
984 | +123456789:-987654321:1111111110 |
985 | &fmul |
986 | abc:abc:NaN |
987 | abc:+0:NaN |
988 | +0:abc:NaN |
989 | +inf:NaNmul:NaN |
990 | +inf:NaNmul:NaN |
991 | NaNmul:+inf:NaN |
992 | NaNmul:-inf:NaN |
993 | +inf:+inf:inf |
994 | +inf:-inf:-inf |
995 | +inf:-inf:-inf |
996 | +inf:+inf:inf |
997 | +inf:123.34:inf |
998 | +inf:-123.34:-inf |
999 | -inf:123.34:-inf |
1000 | -inf:-123.34:inf |
1001 | 123.34:+inf:inf |
1002 | -123.34:+inf:-inf |
1003 | 123.34:-inf:-inf |
1004 | -123.34:-inf:inf |
1005 | +0:+0:0 |
1006 | +0:+1:0 |
1007 | +1:+0:0 |
1008 | +0:-1:0 |
1009 | -1:+0:0 |
1010 | +123456789123456789:+0:0 |
1011 | +0:+123456789123456789:0 |
1012 | -1:-1:1 |
1013 | -1:+1:-1 |
1014 | +1:-1:-1 |
1015 | +1:+1:1 |
1016 | +2:+3:6 |
1017 | -2:+3:-6 |
1018 | +2:-3:-6 |
1019 | -2:-3:6 |
1020 | +111:+111:12321 |
1021 | +10101:+10101:102030201 |
1022 | +1001001:+1001001:1002003002001 |
1023 | +100010001:+100010001:10002000300020001 |
1024 | +10000100001:+10000100001:100002000030000200001 |
1025 | +11111111111:+9:99999999999 |
1026 | +22222222222:+9:199999999998 |
1027 | +33333333333:+9:299999999997 |
1028 | +44444444444:+9:399999999996 |
1029 | +55555555555:+9:499999999995 |
1030 | +66666666666:+9:599999999994 |
1031 | +77777777777:+9:699999999993 |
1032 | +88888888888:+9:799999999992 |
1033 | +99999999999:+9:899999999991 |
1034 | 6:120:720 |
1035 | 10:10000:100000 |
1036 | &fdiv-list |
1037 | 0:0:NaN,NaN |
1038 | 0:1:0,0 |
1039 | 9:4:2.25,1 |
1040 | 9:5:1.8,4 |
1041 | &fdiv |
1042 | $div_scale = 40; $round_mode = 'even' |
1043 | abc:abc:NaN |
1044 | abc:+1:abc:NaN |
1045 | +1:abc:NaN |
1046 | -1:abc:NaN |
1047 | 0:abc:NaN |
1048 | +0:+0:NaN |
1049 | +0:+1:0 |
1050 | +1:+0:inf |
1051 | +3214:+0:inf |
1052 | +0:-1:0 |
1053 | -1:+0:-inf |
1054 | -3214:+0:-inf |
1055 | +1:+1:1 |
1056 | -1:-1:1 |
1057 | +1:-1:-1 |
1058 | -1:+1:-1 |
1059 | +1:+2:0.5 |
1060 | +2:+1:2 |
1061 | 123:+inf:0 |
1062 | 123:-inf:0 |
1063 | +10:+5:2 |
1064 | +100:+4:25 |
1065 | +1000:+8:125 |
1066 | +10000:+16:625 |
1067 | +10000:-16:-625 |
1068 | +999999999999:+9:111111111111 |
1069 | +999999999999:+99:10101010101 |
1070 | +999999999999:+999:1001001001 |
1071 | +999999999999:+9999:100010001 |
1072 | +999999999999999:+99999:10000100001 |
1073 | +1000000000:+9:111111111.1111111111111111111111111111111 |
1074 | +2000000000:+9:222222222.2222222222222222222222222222222 |
1075 | +3000000000:+9:333333333.3333333333333333333333333333333 |
1076 | +4000000000:+9:444444444.4444444444444444444444444444444 |
1077 | +5000000000:+9:555555555.5555555555555555555555555555556 |
1078 | +6000000000:+9:666666666.6666666666666666666666666666667 |
1079 | +7000000000:+9:777777777.7777777777777777777777777777778 |
1080 | +8000000000:+9:888888888.8888888888888888888888888888889 |
1081 | +9000000000:+9:1000000000 |
1082 | +35500000:+113:314159.2920353982300884955752212389380531 |
1083 | +71000000:+226:314159.2920353982300884955752212389380531 |
1084 | +106500000:+339:314159.2920353982300884955752212389380531 |
1085 | +1000000000:+3:333333333.3333333333333333333333333333333 |
1086 | 2:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447 |
1087 | 123456:1:123456 |
1088 | $div_scale = 20 |
1089 | +1000000000:+9:111111111.11111111111 |
1090 | +2000000000:+9:222222222.22222222222 |
1091 | +3000000000:+9:333333333.33333333333 |
1092 | +4000000000:+9:444444444.44444444444 |
1093 | +5000000000:+9:555555555.55555555556 |
1094 | +6000000000:+9:666666666.66666666667 |
1095 | +7000000000:+9:777777777.77777777778 |
1096 | +8000000000:+9:888888888.88888888889 |
1097 | +9000000000:+9:1000000000 |
1098 | 1:10:0.1 |
1099 | 1:100:0.01 |
1100 | 1:1000:0.001 |
1101 | 1:10000:0.0001 |
1102 | 1:504:0.001984126984126984127 |
1103 | 2:1.987654321:1.0062111801179738436 |
1104 | 123456789.123456789123456789123456789:1:123456789.12345678912 |
1105 | # the next two cases are the "old" behaviour, but are now (>v0.01) different |
1106 | #+35500000:+113:314159.292035398230088 |
1107 | #+71000000:+226:314159.292035398230088 |
1108 | +35500000:+113:314159.29203539823009 |
1109 | +71000000:+226:314159.29203539823009 |
1110 | +106500000:+339:314159.29203539823009 |
1111 | +1000000000:+3:333333333.33333333333 |
1112 | $div_scale = 1 |
1113 | # round to accuracy 1 after bdiv |
1114 | +124:+3:40 |
1115 | 123456789.1234:1:100000000 |
1116 | # reset scale for further tests |
1117 | $div_scale = 40 |
1118 | &fmod |
1119 | +9:4:1 |
1120 | +9:5:4 |
1121 | +9000:56:40 |
1122 | +56:9000:56 |
1123 | # inf handling, see table in doc |
1124 | 0:inf:0 |
1125 | 0:-inf:0 |
1126 | 5:inf:5 |
1127 | 5:-inf:5 |
1128 | -5:inf:-5 |
1129 | -5:-inf:-5 |
1130 | inf:5:0 |
1131 | -inf:5:0 |
1132 | inf:-5:0 |
1133 | -inf:-5:0 |
1134 | 5:5:0 |
1135 | -5:-5:0 |
1136 | inf:inf:NaN |
1137 | -inf:-inf:NaN |
1138 | -inf:inf:NaN |
1139 | inf:-inf:NaN |
1140 | 8:0:8 |
1141 | inf:0:inf |
1142 | # exceptions to reminder rule |
1143 | -inf:0:-inf |
1144 | -8:0:-8 |
1145 | 0:0:NaN |
1146 | abc:abc:NaN |
1147 | abc:1:abc:NaN |
1148 | 1:abc:NaN |
1149 | 0:0:NaN |
1150 | 0:1:0 |
1151 | 1:0:1 |
1152 | 0:-1:0 |
1153 | -1:0:-1 |
1154 | 1:1:0 |
1155 | -1:-1:0 |
1156 | 1:-1:0 |
1157 | -1:1:0 |
1158 | 1:2:1 |
1159 | 2:1:0 |
1160 | 1000000000:9:1 |
1161 | 2000000000:9:2 |
1162 | 3000000000:9:3 |
1163 | 4000000000:9:4 |
1164 | 5000000000:9:5 |
1165 | 6000000000:9:6 |
1166 | 7000000000:9:7 |
1167 | 8000000000:9:8 |
1168 | 9000000000:9:0 |
1169 | 35500000:113:33 |
1170 | 71000000:226:66 |
1171 | 106500000:339:99 |
1172 | 1000000000:3:1 |
1173 | 10:5:0 |
1174 | 100:4:0 |
1175 | 1000:8:0 |
1176 | 10000:16:0 |
1177 | 999999999999:9:0 |
1178 | 999999999999:99:0 |
1179 | 999999999999:999:0 |
1180 | 999999999999:9999:0 |
1181 | 999999999999999:99999:0 |
1182 | -9:+5:1 |
1183 | +9:-5:-1 |
1184 | -9:-5:-4 |
1185 | -5:3:1 |
1186 | -2:3:1 |
1187 | 4:3:1 |
1188 | 1:3:1 |
1189 | -5:-3:-2 |
1190 | -2:-3:-2 |
1191 | 4:-3:-2 |
1192 | 1:-3:-2 |
1193 | 4095:4095:0 |
1194 | 100041000510123:3:0 |
1195 | 152403346:12345:4321 |
1196 | 87654321:87654321:0 |
1197 | # now some floating point tests |
9b924220 |
1198 | 123:2.5:0.5 |
1199 | 1230:2.5:0 |
1200 | 123.4:2.5:0.9 |
1201 | 123e1:25:5 |
184f15d5 |
1202 | &ffac |
1203 | Nanfac:NaN |
1204 | -1:NaN |
9b924220 |
1205 | +inf:inf |
1206 | -inf:NaN |
184f15d5 |
1207 | 0:1 |
1208 | 1:1 |
1209 | 2:2 |
1210 | 3:6 |
1211 | 4:24 |
1212 | 5:120 |
1213 | 6:720 |
1214 | 10:3628800 |
1215 | 11:39916800 |
1216 | 12:479001600 |
9b924220 |
1217 | &froot |
1218 | # sqrt() |
1219 | +0:2:0 |
1220 | +1:2:1 |
1221 | -1:2:NaN |
1222 | # -$x ** (1/2) => -$y, but not in froot() |
1223 | -123.456:2:NaN |
1224 | +inf:2:inf |
1225 | -inf:2:NaN |
1226 | 2:2:1.41421356237309504880168872420969807857 |
1227 | -2:2:NaN |
1228 | 4:2:2 |
1229 | 9:2:3 |
1230 | 16:2:4 |
1231 | 100:2:10 |
1232 | 123.456:2:11.11107555549866648462149404118219234119 |
1233 | 15241.38393:2:123.4559999756998444766131352122991626468 |
1234 | 1.44:2:1.2 |
1235 | 12:2:3.464101615137754587054892683011744733886 |
1236 | 0.49:2:0.7 |
1237 | 0.0049:2:0.07 |
1238 | # invalid ones |
1239 | 1:NaN:NaN |
1240 | -1:NaN:NaN |
1241 | 0:NaN:NaN |
1242 | -inf:NaN:NaN |
1243 | +inf:NaN:NaN |
1244 | NaN:0:NaN |
1245 | NaN:2:NaN |
1246 | NaN:inf:NaN |
1247 | NaN:inf:NaN |
1248 | 12:-inf:NaN |
1249 | 12:inf:NaN |
1250 | +0:0:NaN |
1251 | +1:0:NaN |
1252 | -1:0:NaN |
1253 | -2:0:NaN |
1254 | -123.45:0:NaN |
1255 | +inf:0:NaN |
1256 | 12:1:12 |
1257 | -12:1:NaN |
1258 | 8:-1:NaN |
1259 | -8:-1:NaN |
1260 | # cubic root |
1261 | 8:3:2 |
1262 | -8:3:NaN |
1263 | # fourths root |
1264 | 16:4:2 |
1265 | 81:4:3 |
1266 | # see t/bigroot() for more tests |
184f15d5 |
1267 | &fsqrt |
1268 | +0:0 |
1269 | -1:NaN |
1270 | -2:NaN |
1271 | -16:NaN |
1272 | -123.45:NaN |
1273 | nanfsqrt:NaN |
1274 | +inf:inf |
1275 | -inf:NaN |
1276 | 1:1 |
1277 | 2:1.41421356237309504880168872420969807857 |
1278 | 4:2 |
1279 | 9:3 |
1280 | 16:4 |
1281 | 100:10 |
1282 | 123.456:11.11107555549866648462149404118219234119 |
1283 | 15241.38393:123.4559999756998444766131352122991626468 |
1284 | 1.44:1.2 |
1285 | # sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4 |
1286 | 1.44E10:120000 |
1287 | 2e10:141421.356237309504880168872420969807857 |
1288 | 144e20:120000000000 |
1289 | # proved to be an endless loop under 7-9 |
1290 | 12:3.464101615137754587054892683011744733886 |
9b924220 |
1291 | 0.49:0.7 |
1292 | 0.0049:0.07 |
184f15d5 |
1293 | &is_nan |
1294 | 123:0 |
1295 | abc:1 |
1296 | NaN:1 |
1297 | -123:0 |
1298 | &is_inf |
1299 | +inf::1 |
1300 | -inf::1 |
1301 | abc::0 |
1302 | 1::0 |
1303 | NaN::0 |
1304 | -1::0 |
1305 | +inf:-:0 |
1306 | +inf:+:1 |
1307 | -inf:-:1 |
1308 | -inf:+:0 |
1309 | # it must be exactly /^[+-]inf$/ |
1310 | +infinity::0 |
1311 | -infinity::0 |
1312 | &is_odd |
1313 | abc:0 |
1314 | 0:0 |
1315 | -1:1 |
1316 | -3:1 |
1317 | 1:1 |
1318 | 3:1 |
1319 | 1000001:1 |
1320 | 1000002:0 |
1321 | +inf:0 |
1322 | -inf:0 |
1323 | 123.45:0 |
1324 | -123.45:0 |
1325 | 2:0 |
1326 | &is_int |
1327 | NaNis_int:0 |
1328 | 0:1 |
1329 | 1:1 |
1330 | 2:1 |
1331 | -2:1 |
1332 | -1:1 |
1333 | -inf:0 |
1334 | +inf:0 |
1335 | 123.4567:0 |
1336 | -0.1:0 |
1337 | -0.002:0 |
1338 | &is_even |
1339 | abc:0 |
1340 | 0:1 |
1341 | -1:0 |
1342 | -3:0 |
1343 | 1:0 |
1344 | 3:0 |
1345 | 1000001:0 |
1346 | 1000002:1 |
1347 | 2:1 |
1348 | +inf:0 |
1349 | -inf:0 |
1350 | 123.456:0 |
1351 | -123.456:0 |
1352 | 0.01:0 |
1353 | -0.01:0 |
1354 | 120:1 |
1355 | 1200:1 |
1356 | -1200:1 |
1357 | &is_positive |
1358 | 0:1 |
1359 | 1:1 |
1360 | -1:0 |
1361 | -123:0 |
1362 | NaN:0 |
1363 | -inf:0 |
1364 | +inf:1 |
1365 | &is_negative |
1366 | 0:0 |
1367 | 1:0 |
1368 | -1:1 |
1369 | -123:1 |
1370 | NaN:0 |
1371 | -inf:1 |
1372 | +inf:0 |
1373 | &parts |
1374 | 0:0 1 |
1375 | 1:1 0 |
1376 | 123:123 0 |
1377 | -123:-123 0 |
1378 | -1200:-12 2 |
1379 | NaNparts:NaN NaN |
1380 | +inf:inf inf |
1381 | -inf:-inf inf |
1382 | &exponent |
1383 | 0:1 |
1384 | 1:0 |
1385 | 123:0 |
1386 | -123:0 |
1387 | -1200:2 |
1388 | +inf:inf |
1389 | -inf:inf |
1390 | NaNexponent:NaN |
1391 | &mantissa |
1392 | 0:0 |
1393 | 1:1 |
1394 | 123:123 |
1395 | -123:-123 |
1396 | -1200:-12 |
1397 | +inf:inf |
1398 | -inf:-inf |
1399 | NaNmantissa:NaN |
1400 | &length |
1401 | 123:3 |
1402 | -123:3 |
1403 | 0:1 |
1404 | 1:1 |
1405 | 12345678901234567890:20 |
1406 | &is_zero |
1407 | NaNzero:0 |
1408 | +inf:0 |
1409 | -inf:0 |
1410 | 0:1 |
1411 | -1:0 |
1412 | 1:0 |
1413 | &is_one |
1414 | NaNone:0 |
1415 | +inf:0 |
1416 | -inf:0 |
1417 | 0:0 |
1418 | 2:0 |
1419 | 1:1 |
1420 | -1:0 |
1421 | -2:0 |
1422 | &ffloor |
1423 | 0:0 |
1424 | abc:NaN |
1425 | +inf:inf |
1426 | -inf:-inf |
1427 | 1:1 |
1428 | -51:-51 |
1429 | -51.2:-52 |
1430 | 12.2:12 |
9b924220 |
1431 | 0.12345:0 |
1432 | 0.123456:0 |
1433 | 0.1234567:0 |
1434 | 0.12345678:0 |
1435 | 0.123456789:0 |
184f15d5 |
1436 | &fceil |
1437 | 0:0 |
1438 | abc:NaN |
1439 | +inf:inf |
1440 | -inf:-inf |
1441 | 1:1 |
1442 | -51:-51 |
1443 | -51.2:-51 |
1444 | 12.2:13 |