Update CPANPLUS to 0.79_02
[p5sagit/p5-mst-13.2.git] / lib / Math / BigRat / t / bigfltpm.inc
CommitLineData
184f15d5 1#include this file into another test for subclass testing...
2
3ok ($class->config()->{lib},$CL);
4
9b924220 5use strict;
6
184f15d5 7while (<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);
155ok ($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
191ok ($class->fzero(),0);
192ok ($class->fone(),1);
193ok ($class->fone('+'),1);
194ok ($class->fone('-'),-1);
195ok ($class->fnan(),'NaN');
196ok ($class->finf(),'inf');
197ok ($class->finf('+'),'inf');
198ok ($class->finf('-'),'-inf');
199ok ($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);
208ok ($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
246ok ($class->new(-1)->is_one(),0);
247ok ($class->new(-1)->is_one('-'),1);
184f15d5 248
2491; # all done
250
251###############################################################################
252# Perl 5.005 does not like ok ($x,undef)
253
254sub 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 2650::NaN
266-1::NaN
267-2::NaN
268# base > 0, base != 1
2692:-1:NaN
2702:0:NaN
2712:1:NaN
272# log(1) is always 1, regardless of $base
2731::0
2741:1:0
2751: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 2872::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 2941::0
184f15d5 295&frsft
296NaNfrsft:2:NaN
2970:2:0
2981:1:0.5
2992:1:1
3004:1:2
301123:1:61.5
30232:3:4
303&flsft
304NaNflsft:0:NaN
3052:1:4
3064:3:32
3075:3:40
3081:2:4
3090:5:0
310&fnorm
3111:1
312-0:0
313fnormNaN:NaN
314+inf:inf
315-inf:-inf
316123:123
317-123.4567:-123.4567
318# invalid inputs
3191__2:NaN
3201E1__2:NaN
32111__2E2:NaN
322#1.E3:NaN
323.2E-3.:NaN
324#1e3e4:NaN
325.2E2:20
326&as_number
3270:0
3281:1
3291.2:1
3302.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
3350.000641:0
3360.0006412:0
3370.00064123:0
3380.000641234:0
3390.0006412345:0
3400.00064123456:0
3410.000641234567:0
3420.0006412345678:0
3430.00064123456789:0
3440.1:0
3450.01:0
3460.001:0
3470.0001:0
3480.00001:0
3490.000001:0
3500.0000001:0
3510.00000001:0
3520.000000001:0
3530.0000000001:0
3540.00000000001:0
3550.12345:0
3560.123456:0
3570.1234567:0
3580.12345678:0
3590.123456789:0
184f15d5 360&finf
3611:+:inf
3622:-:-inf
3633:abc:inf
9b924220 364&as_hex
365+inf:inf
366-inf:-inf
367hexNaN:NaN
3680:0x0
3695:0x5
370-5:-0x5
371&as_bin
372+inf:inf
373-inf:-inf
374hexNaN:NaN
3750:0b0
3765:0b101
377-5:-0b101
184f15d5 378&numify
9b924220 379# uses bsstr() so 5 => 5e+0 to be compatible w/ Perls output
184f15d5 3800:0e+1
381+1:1e+0
3821234:1234e+0
383NaN:NaN
384+inf:inf
385-inf:-inf
9b924220 386-5:-5e+0
387100:1e+2
388-100:-1e+2
184f15d5 389&fnan
390abc:NaN
3912:NaN
392-2:NaN
3930:NaN
394&fone
3952:+:1
396-2:-:-1
397-2:+:1
3982:-:-1
3990::1
400-2::1
401abc::1
4022:abc:1
403&fsstr
404+inf:inf
405-inf:-inf
406abcfsstr:NaN
9b924220 407-abcfsstr:NaN
184f15d5 4081234.567:1234567e-3
9b924220 409123:123e+0
410-5:-5e+0
411-100:-1e+2
184f15d5 412&fstr
413+inf:::inf
414-inf:::-inf
415abcfstr:::NaN
4161234.567:9::1234.56700
4171234.567::-6:1234.567000
41812345:5::12345
4190.001234:6::0.00123400
4200.001234::-8:0.00123400
4210:4::0
4220::-4:0.0000
423&fnorm
424inf:inf
425+inf:inf
426-inf:-inf
427+infinity:NaN
428+-inf:NaN
429abc:NaN
430 1 a:NaN
4311bcd2:NaN
43211111b:NaN
433+1z:NaN
434-1z:NaN
9b924220 4350e999:0
4360e-999:0
437-0e999:0
438-0e-999:0
184f15d5 4390:0
440+0:0
441+00:0
442+0_0_0:0
443000000_0000000_00000:0
444-0:0
445-0000:0
446+1:1
447+01:1
448+001:1
449+00000100000:100000
450123456789:123456789
451-1:-1
452-01:-1
453-001:-1
454-123456789:-123456789
455-00000100000:-100000
456123.456a:NaN
457123.456:123.456
4580.01:0.01
459.002:0.002
460+.2:0.2
461-0.0003:-0.0003
462-.0000000004:-0.0000000004
463123456E2:12345600
464123456E-2:1234.56
465-123456E2:-12345600
466-123456E-2:-1234.56
4671e1:10
4682e-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
4802:2:4
4811:2:1
4821:3:1
483-1:2:1
484-1:3:-1
485123.456:2:15241.383936
4862:-2:0.25
4872:-3:0.125
488128:-2:0.00006103515625
489abc:123.456:NaN
490123.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)
4972: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
504fnegNaN: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
515fabsNaN: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
5290:5:0
530NaNfround: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
5880:5:0
589NaNffround: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
6170.05:0:0
6180.5:0:0
6190.51:0:0
6200.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
6350.05:0:0
6360.5:0:0
6370.51:0:1
6380.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
6530.05:0:0
6540.5:0:1
6550.51:0:1
6560.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
6710.05:0:0
6720.5:0:0
6730.51:0:1
6740.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
6890.05:0:0
6900.5:0:1
6910.51:0:1
6920.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
7070.05:0:0
7080.5:0:0
7090.51:0:1
7100.41:0:0
7110.01234567:-3:0.012
7120.01234567:-4:0.0123
7130.01234567:-5:0.01235
7140.01234567:-6:0.012346
7150.01234567:-7:0.0123457
7160.01234567:-8:0.01234567
7170.01234567:-9:0.012345670
7180.01234567:-12:0.012345670000
719&fcmp
720fcmpNaN:fcmpNaN:
721fcmpNaN:+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
7460:0.01:-1
7470:0.0001:-1
7480:-0.0001:1
7490:-0.1:1
7500.1:0:1
7510.00001:0:1
752-0.0001:0:-1
753-0.1:0:-1
7540:0.0001234:-1
7550:-0.0001234:1
7560.0001234:0:1
757-0.0001234:0:-1
7580.0001:0.0005:-1
7590.0005:0.0001:1
7600.005:0.0001:1
7610.001:0.0005:1
7620.000001:0.0005:-1
7630.00000123:0.0005:-1
7640.00512:0.0001:1
7650.005:0.000112:1
7660.00123:0.0005:1
7671.5:2:-1
7682:1.5:1
7691.54321:234:-1
770234: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:
786NaN:inf:
787-inf:NaN:
788NaN:-inf:
789&facmp
790fcmpNaN:fcmpNaN:
791fcmpNaN:+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
8160:0.01:-1
8170:0.0001:-1
8180:-0.0001:-1
8190:-0.1:-1
8200.1:0:1
8210.00001:0:1
822-0.0001:0:1
823-0.1:0:1
8240:0.0001234:-1
8250:-0.0001234:-1
8260.0001234:0:1
827-0.0001234:0:1
8280.0001:0.0005:-1
8290.0005:0.0001:1
8300.005:0.0001:1
8310.001:0.0005:1
8320.000001:0.0005:-1
8330.00000123:0.0005:-1
8340.00512:0.0001:1
8350.005:0.000112:1
8360.00123:0.0005:1
8371.5:2:-1
8382:1.5:1
8391.54321:234:-1
840234: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
8545:inf:-1
855-1:inf:-1
8565:-inf:-1
857-1:-inf:-1
858# return undef
859+inf:facmpNaN:
860facmpNaN:inf:
861-inf:facmpNaN:
862facmpNaN:-inf:
863&fdec
864fdecNaN:NaN
865+inf:inf
866-inf:-inf
867+0:-1
868+1:0
869-1:-2
8701.23:0.23
871-1.23:-2.23
872100:99
873101:100
874-100:-101
875-99:-100
876-98:-99
87799:98
878&finc
879fincNaN:NaN
880+inf:inf
881-inf:-inf
882+0:1
883+1:2
884-1:0
8851.23:2.23
886-1.23:-0.23
887100:101
888-100:-99
889-99:-98
890-101:-100
89199:100
892&fadd
893abc:abc:NaN
894abc:+0:NaN
895+0:abc:NaN
9b924220 896+inf:-inf:NaN
897-inf:+inf:NaN
184f15d5 898+inf:+inf:inf
899-inf:-inf:-inf
900baddNaN:+inf:NaN
901baddNaN:+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
9380.001234:0.0001234:0.0013574
939&fsub
940abc:abc:NaN
941abc:+0:NaN
942+0:abc:NaN
943+inf:-inf:inf
944-inf:+inf:-inf
9b924220 945+inf:+inf:NaN
946-inf:-inf:NaN
184f15d5 947baddNaN:+inf:NaN
948baddNaN:+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
986abc:abc:NaN
987abc:+0:NaN
988+0:abc:NaN
989+inf:NaNmul:NaN
990+inf:NaNmul:NaN
991NaNmul:+inf:NaN
992NaNmul:-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
1001123.34:+inf:inf
1002-123.34:+inf:-inf
1003123.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
10346:120:720
103510:10000:100000
1036&fdiv-list
10370:0:NaN,NaN
10380:1:0,0
10399:4:2.25,1
10409:5:1.8,4
1041&fdiv
1042$div_scale = 40; $round_mode = 'even'
1043abc:abc:NaN
1044abc:+1:abc:NaN
1045+1:abc:NaN
1046-1:abc:NaN
10470: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
1061123:+inf:0
1062123:-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
10862:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447
1087123456: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
10981:10:0.1
10991:100:0.01
11001:1000:0.001
11011:10000:0.0001
11021:504:0.001984126984126984127
11032:1.987654321:1.0062111801179738436
1104123456789.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
1115123456789.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
11240:inf:0
11250:-inf:0
11265:inf:5
11275:-inf:5
1128-5:inf:-5
1129-5:-inf:-5
1130inf:5:0
1131-inf:5:0
1132inf:-5:0
1133-inf:-5:0
11345:5:0
1135-5:-5:0
1136inf:inf:NaN
1137-inf:-inf:NaN
1138-inf:inf:NaN
1139inf:-inf:NaN
11408:0:8
1141inf:0:inf
1142# exceptions to reminder rule
1143-inf:0:-inf
1144-8:0:-8
11450:0:NaN
1146abc:abc:NaN
1147abc:1:abc:NaN
11481:abc:NaN
11490:0:NaN
11500:1:0
11511:0:1
11520:-1:0
1153-1:0:-1
11541:1:0
1155-1:-1:0
11561:-1:0
1157-1:1:0
11581:2:1
11592:1:0
11601000000000:9:1
11612000000000:9:2
11623000000000:9:3
11634000000000:9:4
11645000000000:9:5
11656000000000:9:6
11667000000000:9:7
11678000000000:9:8
11689000000000:9:0
116935500000:113:33
117071000000:226:66
1171106500000:339:99
11721000000000:3:1
117310:5:0
1174100:4:0
11751000:8:0
117610000:16:0
1177999999999999:9:0
1178999999999999:99:0
1179999999999999:999:0
1180999999999999:9999:0
1181999999999999999:99999:0
1182-9:+5:1
1183+9:-5:-1
1184-9:-5:-4
1185-5:3:1
1186-2:3:1
11874:3:1
11881:3:1
1189-5:-3:-2
1190-2:-3:-2
11914:-3:-2
11921:-3:-2
11934095:4095:0
1194100041000510123:3:0
1195152403346:12345:4321
119687654321:87654321:0
1197# now some floating point tests
9b924220 1198123:2.5:0.5
11991230:2.5:0
1200123.4:2.5:0.9
1201123e1:25:5
184f15d5 1202&ffac
1203Nanfac:NaN
1204-1:NaN
9b924220 1205+inf:inf
1206-inf:NaN
184f15d5 12070:1
12081:1
12092:2
12103:6
12114:24
12125:120
12136:720
121410:3628800
121511:39916800
121612: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
12262:2:1.41421356237309504880168872420969807857
1227-2:2:NaN
12284:2:2
12299:2:3
123016:2:4
1231100:2:10
1232123.456:2:11.11107555549866648462149404118219234119
123315241.38393:2:123.4559999756998444766131352122991626468
12341.44:2:1.2
123512:2:3.464101615137754587054892683011744733886
12360.49:2:0.7
12370.0049:2:0.07
1238# invalid ones
12391:NaN:NaN
1240-1:NaN:NaN
12410:NaN:NaN
1242-inf:NaN:NaN
1243+inf:NaN:NaN
1244NaN:0:NaN
1245NaN:2:NaN
1246NaN:inf:NaN
1247NaN:inf:NaN
124812:-inf:NaN
124912: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
125612:1:12
1257-12:1:NaN
12588:-1:NaN
1259-8:-1:NaN
1260# cubic root
12618:3:2
1262-8:3:NaN
1263# fourths root
126416:4:2
126581: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
1273nanfsqrt:NaN
1274+inf:inf
1275-inf:NaN
12761:1
12772:1.41421356237309504880168872420969807857
12784:2
12799:3
128016:4
1281100:10
1282123.456:11.11107555549866648462149404118219234119
128315241.38393:123.4559999756998444766131352122991626468
12841.44:1.2
1285# sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4
12861.44E10:120000
12872e10:141421.356237309504880168872420969807857
1288144e20:120000000000
1289# proved to be an endless loop under 7-9
129012:3.464101615137754587054892683011744733886
9b924220 12910.49:0.7
12920.0049:0.07
184f15d5 1293&is_nan
1294123:0
1295abc:1
1296NaN:1
1297-123:0
1298&is_inf
1299+inf::1
1300-inf::1
1301abc::0
13021::0
1303NaN::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
1313abc:0
13140:0
1315-1:1
1316-3:1
13171:1
13183:1
13191000001:1
13201000002:0
1321+inf:0
1322-inf:0
1323123.45:0
1324-123.45:0
13252:0
1326&is_int
1327NaNis_int:0
13280:1
13291:1
13302:1
1331-2:1
1332-1:1
1333-inf:0
1334+inf:0
1335123.4567:0
1336-0.1:0
1337-0.002:0
1338&is_even
1339abc:0
13400:1
1341-1:0
1342-3:0
13431:0
13443:0
13451000001:0
13461000002:1
13472:1
1348+inf:0
1349-inf:0
1350123.456:0
1351-123.456:0
13520.01:0
1353-0.01:0
1354120:1
13551200:1
1356-1200:1
1357&is_positive
13580:1
13591:1
1360-1:0
1361-123:0
1362NaN:0
1363-inf:0
1364+inf:1
1365&is_negative
13660:0
13671:0
1368-1:1
1369-123:1
1370NaN:0
1371-inf:1
1372+inf:0
1373&parts
13740:0 1
13751:1 0
1376123:123 0
1377-123:-123 0
1378-1200:-12 2
1379NaNparts:NaN NaN
1380+inf:inf inf
1381-inf:-inf inf
1382&exponent
13830:1
13841:0
1385123:0
1386-123:0
1387-1200:2
1388+inf:inf
1389-inf:inf
1390NaNexponent:NaN
1391&mantissa
13920:0
13931:1
1394123:123
1395-123:-123
1396-1200:-12
1397+inf:inf
1398-inf:-inf
1399NaNmantissa:NaN
1400&length
1401123:3
1402-123:3
14030:1
14041:1
140512345678901234567890:20
1406&is_zero
1407NaNzero:0
1408+inf:0
1409-inf:0
14100:1
1411-1:0
14121:0
1413&is_one
1414NaNone:0
1415+inf:0
1416-inf:0
14170:0
14182:0
14191:1
1420-1:0
1421-2:0
1422&ffloor
14230:0
1424abc:NaN
1425+inf:inf
1426-inf:-inf
14271:1
1428-51:-51
1429-51.2:-52
143012.2:12
9b924220 14310.12345:0
14320.123456:0
14330.1234567:0
14340.12345678:0
14350.123456789:0
184f15d5 1436&fceil
14370:0
1438abc:NaN
1439+inf:inf
1440-inf:-inf
14411:1
1442-51:-51
1443-51.2:-51
144412.2:13