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