Fix a bug in the cloning of regexps
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigfltpm.inc
CommitLineData
ee15d750 1#include this file into another test for subclass testing...
b3abae2a 2
3ok ($class->config()->{lib},$CL);
4
56d9de68 5use strict;
6
ee15d750 7while (<DATA>)
8 {
d614cd8b 9 chomp;
ee15d750 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]\");";
ee15d750 34 if ($f eq "fnorm")
35 {
36 $try .= "\$x;";
37 } elsif ($f eq "finf") {
38 $try .= "\$x->finf('$args[1]');";
027dc388 39 } elsif ($f eq "is_inf") {
40 $try .= "\$x->is_inf('$args[1]');";
ee15d750 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]);";
45 $try .= '$x->fstr();';
ee15d750 46 } elsif ($f eq "parts") {
48b581a2 47 # ->bstr() to see if an object is returned
ee15d750 48 $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();';
49 $try .= '"$a $b";';
ee15d750 50 } elsif ($f eq "exponent") {
48b581a2 51 # ->bstr() to see if an object is returned
ee15d750 52 $try .= '$x->exponent()->bstr();';
53 } elsif ($f eq "mantissa") {
48b581a2 54 # ->bstr() to see if an object is returned
ee15d750 55 $try .= '$x->mantissa()->bstr();';
56d9de68 56 } elsif ($f =~ /^(numify|length|as_number|as_hex|as_bin)$/) {
57 $try .= "\$x->$f();";
b3abae2a 58 # some unary ops (test the fxxx form, since that is done by AUTOLOAD)
027dc388 59 } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|abs)$/) {
394e6ffb 60 $try .= "\$x->f$1();";
027dc388 61 # some is_xxx test function
b3abae2a 62 } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan|int)$/) {
027dc388 63 $try .= "\$x->$f();";
ee15d750 64 } elsif ($f eq "finc") {
65 $try .= '++$x;';
66 } elsif ($f eq "fdec") {
67 $try .= '--$x;';
68 }elsif ($f eq "fround") {
69 $try .= "$setup; \$x->fround($args[1]);";
70 } elsif ($f eq "ffround") {
71 $try .= "$setup; \$x->ffround($args[1]);";
72 } elsif ($f eq "fsqrt") {
73 $try .= "$setup; \$x->fsqrt();";
b3abae2a 74 } elsif ($f eq "ffac") {
75 $try .= "$setup; \$x->ffac();";
990fb837 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 }
ee15d750 86 }
87 else
88 {
990fb837 89 $try .= "\$y = $class->new(\"$args[1]\");";
ee15d750 90 if ($f eq "fcmp") {
91 $try .= '$x <=> $y;';
92 } elsif ($f eq "facmp") {
93 $try .= '$x->facmp($y);';
94 } elsif ($f eq "fpow") {
95 $try .= '$x ** $y;';
990fb837 96 } elsif ($f eq "froot") {
97 $try .= "$setup; \$x->froot(\$y);";
ee15d750 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;";
b3abae2a 106 } elsif ($f eq "fdiv-list") {
107 $try .= "$setup; join(',',\$x->fdiv(\$y));";
394e6ffb 108 } elsif ($f eq "frsft") {
109 $try .= '$x >> $y;';
110 } elsif ($f eq "flsft") {
111 $try .= '$x << $y;';
ee15d750 112 } elsif ($f eq "fmod") {
113 $try .= '$x % $y;';
114 } else { warn "Unknown op '$f'"; }
115 }
e745a66c 116 # print "# Trying: '$try'\n";
ee15d750 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);
139 if (ref($ans1) eq "$class")
140 {
027dc388 141 # float numbers are normalized (for now), so mantissa shouldn't have
142 # trailing zeros
ee15d750 143 #print $ans1->_trailing_zeros(),"\n";
144 print "# Has trailing zeros after '$try'\n"
9b924220 145 if !ok ($CL->_zeros( $ans1->{_m}), 0);
ee15d750 146 }
147 }
148 } # end pattern or string
149 }
150 } # end while
151
394e6ffb 152# check whether $class->new( Math::BigInt->new()) destroys it
153# ($y == 12 in this case)
ee15d750 154$x = Math::BigInt->new(1200); $y = $class->new($x);
155ok ($y,1200); ok ($x,1200);
156
157###############################################################################
f9a08e12 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
166my $monster = '1e1234567890123456789012345678901234567890';
167
9b924220 168# new and exponent
56d9de68 169ok ($class->new($monster)->bsstr(),
170 '1e+1234567890123456789012345678901234567890');
9b924220 171ok ($class->new($monster)->exponent(),
172 '1234567890123456789012345678901234567890');
f9a08e12 173# cmp
174ok ($class->new($monster) > 0,1);
175
176# sub/mul
177ok ($class->new($monster)->bsub( $monster),0);
178ok ($class->new($monster)->bmul(2)->bsstr(),
179 '2e+1234567890123456789012345678901234567890');
180
9b924220 181# mantissa
182$monster = '1234567890123456789012345678901234567890e2';
183ok ($class->new($monster)->mantissa(),
184 '123456789012345678901234567890123456789');
185
f9a08e12 186###############################################################################
b3abae2a 187# zero,inf,one,nan
ee15d750 188
394e6ffb 189$x = $class->new(2); $x->fzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
190$x = $class->new(2); $x->finf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
191$x = $class->new(2); $x->fone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
192$x = $class->new(2); $x->fnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
56b9c951 193
194###############################################################################
195# bone/binf etc as plain calls (Lite failed them)
196
197ok ($class->fzero(),0);
198ok ($class->fone(),1);
199ok ($class->fone('+'),1);
200ok ($class->fone('-'),-1);
201ok ($class->fnan(),'NaN');
202ok ($class->finf(),'inf');
203ok ($class->finf('+'),'inf');
204ok ($class->finf('-'),'-inf');
205ok ($class->finf('-inf'),'-inf');
61f5c3f5 206
56d9de68 207$class->accuracy(undef); $class->precision(undef); # reset
208
209###############################################################################
210# bug in bsstr()/numify() showed up in after-rounding in bdiv()
211
212$x = $class->new('0.008'); $y = $class->new(2);
213$x->bdiv(3,$y);
214ok ($x,'0.0027');
215
61f5c3f5 216###############################################################################
217# fsqrt() with set global A/P or A/P enabled on $x, also a test whether fsqrt()
218# correctly modifies $x
219
61f5c3f5 220
221$x = $class->new(12); $class->precision(-2); $x->fsqrt(); ok ($x,'3.46');
222
223$class->precision(undef);
224$x = $class->new(12); $class->precision(0); $x->fsqrt(); ok ($x,'3');
225
226$class->precision(-3); $x = $class->new(12); $x->fsqrt(); ok ($x,'3.464');
227
56d9de68 228{
229 no strict 'refs';
230 # A and P set => NaN
231 ${${class}.'::accuracy'} = 4; $x = $class->new(12);
232 $x->fsqrt(3); ok ($x,'NaN');
233 # supplied arg overrides set global
234 $class->precision(undef); $x = $class->new(12); $x->fsqrt(3); ok ($x,'3.46');
235 $class->accuracy(undef); $class->precision(undef); # reset for further tests
236}
237
238#############################################################################
13a12e00 239# can we call objectify (broken until v1.52)
240
56d9de68 241{
242 no strict;
243 $try =
244 '@args' . " = $class" . "::objectify(2,$class,4,5);".'join(" ",@args);';
245 $ans = eval $try;
246 ok ($ans,"$class 4 5");
247}
f9a08e12 248
990fb837 249#############################################################################
250# is_one('-') (broken until v1.64)
251
252ok ($class->new(-1)->is_one(),0);
253ok ($class->new(-1)->is_one('-'),1);
254
394e6ffb 2551; # all done
ee15d750 256
257###############################################################################
258# Perl 5.005 does not like ok ($x,undef)
259
260sub ok_undef
261 {
262 my $x = shift;
263
264 ok (1,1) and return if !defined $x;
265 ok ($x,'undef');
266 }
267
268__DATA__
b3abae2a 269$div_scale = 40;
270&flog
990fb837 2710::NaN
272-1::NaN
273-2::NaN
274# base > 0, base != 1
2752:-1:NaN
2762:0:NaN
2772:1:NaN
278# log(1) is always 1, regardless of $base
2791::0
2801:1:0
2811:2:0
b3abae2a 282# this is too slow for the testsuite
79c55733 283#2:0.6931471805599453094172321214581765680755
b3abae2a 284#2.718281828:0.9999999998311266953289851340574956564911
285#$div_scale = 20;
286#2.718281828:0.99999999983112669533
990fb837 287# too slow, too
b3abae2a 288#123:4.8112184355
79c55733 289$div_scale = 14;
b3abae2a 290#10:0:2.302585092994
61f5c3f5 291#1000:0:6.90775527898214
292#100:0:4.60517018598809
990fb837 2932::0.69314718055995
61f5c3f5 294#3.1415:0:1.14470039286086
990fb837 295# too slow
61f5c3f5 296#12345:0:9.42100640177928
297#0.001:0:-6.90775527898214
b3abae2a 298# reset for further tests
299$div_scale = 40;
990fb837 3001::0
394e6ffb 301&frsft
b3abae2a 302NaNfrsft:2:NaN
394e6ffb 3030:2:0
3041:1:0.5
3052:1:1
3064:1:2
307123:1:61.5
30832:3:4
309&flsft
b3abae2a 310NaNflsft:0:NaN
394e6ffb 3112:1:4
3124:3:32
3135:3:40
3141:2:4
3150:5:0
ee15d750 316&fnorm
3171:1
318-0:0
319fnormNaN:NaN
320+inf:inf
321-inf:-inf
322123:123
323-123.4567:-123.4567
027dc388 324# invalid inputs
3251__2:NaN
3261E1__2:NaN
32711__2E2:NaN
328#1.E3:NaN
329.2E-3.:NaN
330#1e3e4:NaN
331.2E2:20
ee15d750 332&as_number
3330:0
3341:1
3351.2:1
3362.345:2
337-2:-2
338-123.456:-123
339-200:-200
56d9de68 340# test for bug in brsft() not handling cases that return 0
3410.000641:0
3420.0006412:0
3430.00064123:0
3440.000641234:0
3450.0006412345:0
3460.00064123456:0
3470.000641234567:0
3480.0006412345678:0
3490.00064123456789:0
3500.1:0
3510.01:0
3520.001:0
3530.0001:0
3540.00001:0
3550.000001:0
3560.0000001:0
3570.00000001:0
3580.000000001:0
3590.0000000001:0
3600.00000000001:0
990fb837 3610.12345:0
3620.123456:0
3630.1234567:0
3640.12345678:0
3650.123456789:0
ee15d750 366&finf
3671:+:inf
3682:-:-inf
3693:abc:inf
56d9de68 370&as_hex
371+inf:inf
372-inf:-inf
373hexNaN:NaN
3740:0x0
3755:0x5
376-5:-0x5
377&as_bin
378+inf:inf
379-inf:-inf
380hexNaN:NaN
3810:0b0
3825:0b101
383-5:-0b101
ee15d750 384&numify
56d9de68 385# uses bsstr() so 5 => 5e+0 to be compatible w/ Perls output
ee15d750 3860:0e+1
387+1:1e+0
3881234:1234e+0
389NaN:NaN
390+inf:inf
391-inf:-inf
56d9de68 392-5:-5e+0
393100:1e+2
394-100:-1e+2
ee15d750 395&fnan
396abc:NaN
3972:NaN
398-2:NaN
3990:NaN
400&fone
4012:+:1
402-2:-:-1
403-2:+:1
4042:-:-1
4050::1
406-2::1
407abc::1
4082:abc:1
409&fsstr
410+inf:inf
411-inf:-inf
412abcfsstr:NaN
56d9de68 413-abcfsstr:NaN
ee15d750 4141234.567:1234567e-3
56d9de68 415123:123e+0
416-5:-5e+0
417-100:-1e+2
ee15d750 418&fstr
419+inf:::inf
420-inf:::-inf
421abcfstr:::NaN
4221234.567:9::1234.56700
4231234.567::-6:1234.567000
42412345:5::12345
4250.001234:6::0.00123400
4260.001234::-8:0.00123400
4270:4::0
4280::-4:0.0000
429&fnorm
430inf:inf
431+inf:inf
432-inf:-inf
433+infinity:NaN
434+-inf:NaN
435abc:NaN
436 1 a:NaN
4371bcd2:NaN
43811111b:NaN
439+1z:NaN
440-1z:NaN
aef458a0 4410e999:0
4420e-999:0
443-0e999:0
444-0e-999:0
ee15d750 4450:0
446+0:0
447+00:0
448+0_0_0:0
449000000_0000000_00000:0
450-0:0
451-0000:0
452+1:1
453+01:1
454+001:1
455+00000100000:100000
456123456789:123456789
457-1:-1
458-01:-1
459-001:-1
460-123456789:-123456789
461-00000100000:-100000
462123.456a:NaN
463123.456:123.456
4640.01:0.01
465.002:0.002
466+.2:0.2
467-0.0003:-0.0003
468-.0000000004:-0.0000000004
469123456E2:12345600
470123456E-2:1234.56
471-123456E2:-12345600
472-123456E-2:-1234.56
4731e1:10
4742e-11:0.00000000002
475# excercise _split
476 .02e-1:0.002
477 000001:1
478 -00001:-1
479 -1:-1
480 000.01:0.01
481 -000.0023:-0.0023
482 1.1e1:11
483-3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
484-4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004
485&fpow
9b924220 486NaN:1:NaN
4871:NaN:NaN
488NaN:-1:NaN
489-1:NaN:NaN
490NaN:-21:NaN
491-21:NaN:NaN
492NaN:21:NaN
49321:NaN:NaN
4940:0:1
4950:1:0
4960:9:0
4970:-2:inf
ee15d750 4982:2:4
4991:2:1
5001:3:1
501-1:2:1
502-1:3:-1
503123.456:2:15241.383936
5042:-2:0.25
5052:-3:0.125
506128:-2:0.00006103515625
507abc:123.456:NaN
508123.456:abc:NaN
509+inf:123.45:inf
510-inf:123.45:-inf
511+inf:-123.45:inf
512-inf:-123.45:-inf
9b924220 513-2:2:4
514-2:3:-8
515-2:4:16
516-2:5:-32
517-3:2:9
518-3:3:-27
519-3:4:81
520-3:5:-243
79c55733 521# 2 ** 0.5 == sqrt(2)
522# 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0)
5232:0.5:1.41421356237309504880168872420969807857
56b9c951 524#2:0.2:1.148698354997035006798626946777927589444
07d34614 525#6:1.5:14.6969384566990685891837044482353483518
56b9c951 526$div_scale = 20;
527#62.5:12.5:26447206647554886213592.3959144
528$div_scale = 40;
ee15d750 529&fneg
530fnegNaN:NaN
531+inf:-inf
532-inf:inf
533+0:0
534+1:-1
535-1:1
536+123456789:-123456789
537-123456789:123456789
538+123.456789:-123.456789
539-123456.789:123456.789
540&fabs
541fabsNaN:NaN
542+inf:inf
543-inf:inf
544+0:0
545+1:1
546-1:1
547+123456789:123456789
548-123456789:123456789
549+123.456789:123.456789
550-123456.789:123456.789
551&fround
552$round_mode = "trunc"
553+inf:5:inf
554-inf:5:-inf
5550:5:0
556NaNfround:5:NaN
557+10123456789:5:10123000000
558-10123456789:5:-10123000000
559+10123456789.123:5:10123000000
560-10123456789.123:5:-10123000000
561+10123456789:9:10123456700
562-10123456789:9:-10123456700
563+101234500:6:101234000
564-101234500:6:-101234000
565$round_mode = "zero"
566+20123456789:5:20123000000
567-20123456789:5:-20123000000
568+20123456789.123:5:20123000000
569-20123456789.123:5:-20123000000
570+20123456789:9:20123456800
571-20123456789:9:-20123456800
572+201234500:6:201234000
573-201234500:6:-201234000
574$round_mode = "+inf"
575+30123456789:5:30123000000
576-30123456789:5:-30123000000
577+30123456789.123:5:30123000000
578-30123456789.123:5:-30123000000
579+30123456789:9:30123456800
580-30123456789:9:-30123456800
581+301234500:6:301235000
582-301234500:6:-301234000
583$round_mode = "-inf"
584+40123456789:5:40123000000
585-40123456789:5:-40123000000
586+40123456789.123:5:40123000000
587-40123456789.123:5:-40123000000
588+40123456789:9:40123456800
589-40123456789:9:-40123456800
590+401234500:6:401234000
591-401234500:6:-401235000
592$round_mode = "odd"
593+50123456789:5:50123000000
594-50123456789:5:-50123000000
595+50123456789.123:5:50123000000
596-50123456789.123:5:-50123000000
597+50123456789:9:50123456800
598-50123456789:9:-50123456800
599+501234500:6:501235000
600-501234500:6:-501235000
601$round_mode = "even"
602+60123456789:5:60123000000
603-60123456789:5:-60123000000
604+60123456789:9:60123456800
605-60123456789:9:-60123456800
606+601234500:6:601234000
607-601234500:6:-601234000
608+60123456789.0123:5:60123000000
609-60123456789.0123:5:-60123000000
610&ffround
611$round_mode = "trunc"
612+inf:5:inf
613-inf:5:-inf
6140:5:0
615NaNffround:5:NaN
616+1.23:-1:1.2
617+1.234:-1:1.2
618+1.2345:-1:1.2
619+1.23:-2:1.23
620+1.234:-2:1.23
621+1.2345:-2:1.23
622+1.23:-3:1.230
623+1.234:-3:1.234
624+1.2345:-3:1.234
625-1.23:-1:-1.2
626+1.27:-1:1.2
627-1.27:-1:-1.2
628+1.25:-1:1.2
629-1.25:-1:-1.2
630+1.35:-1:1.3
631-1.35:-1:-1.3
632-0.0061234567890:-1:0.0
633-0.0061:-1:0.0
634-0.00612:-1:0.0
635-0.00612:-2:0.00
636-0.006:-1:0.0
637-0.006:-2:0.00
638-0.0006:-2:0.00
639-0.0006:-3:0.000
640-0.0065:-3:/-0\.006|-6e-03
641-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
642-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
6430.05:0:0
6440.5:0:0
6450.51:0:0
6460.41:0:0
647$round_mode = "zero"
648+2.23:-1:/2.2(?:0{5}\d+)?
649-2.23:-1:/-2.2(?:0{5}\d+)?
650+2.27:-1:/2.(?:3|29{5}\d+)
651-2.27:-1:/-2.(?:3|29{5}\d+)
652+2.25:-1:/2.2(?:0{5}\d+)?
653-2.25:-1:/-2.2(?:0{5}\d+)?
654+2.35:-1:/2.(?:3|29{5}\d+)
655-2.35:-1:/-2.(?:3|29{5}\d+)
656-0.0065:-1:0.0
657-0.0065:-2:/-0\.01|-1e-02
658-0.0065:-3:/-0\.006|-6e-03
659-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
660-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
6610.05:0:0
6620.5:0:0
6630.51:0:1
6640.41:0:0
665$round_mode = "+inf"
666+3.23:-1:/3.2(?:0{5}\d+)?
667-3.23:-1:/-3.2(?:0{5}\d+)?
668+3.27:-1:/3.(?:3|29{5}\d+)
669-3.27:-1:/-3.(?:3|29{5}\d+)
670+3.25:-1:/3.(?:3|29{5}\d+)
671-3.25:-1:/-3.2(?:0{5}\d+)?
672+3.35:-1:/3.(?:4|39{5}\d+)
673-3.35:-1:/-3.(?:3|29{5}\d+)
674-0.0065:-1:0.0
675-0.0065:-2:/-0\.01|-1e-02
676-0.0065:-3:/-0\.006|-6e-03
677-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
678-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
6790.05:0:0
6800.5:0:1
6810.51:0:1
6820.41:0:0
683$round_mode = "-inf"
684+4.23:-1:/4.2(?:0{5}\d+)?
685-4.23:-1:/-4.2(?:0{5}\d+)?
686+4.27:-1:/4.(?:3|29{5}\d+)
687-4.27:-1:/-4.(?:3|29{5}\d+)
688+4.25:-1:/4.2(?:0{5}\d+)?
689-4.25:-1:/-4.(?:3|29{5}\d+)
690+4.35:-1:/4.(?:3|29{5}\d+)
691-4.35:-1:/-4.(?:4|39{5}\d+)
692-0.0065:-1:0.0
693-0.0065:-2:/-0\.01|-1e-02
694-0.0065:-3:/-0\.007|-7e-03
695-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
696-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
6970.05:0:0
6980.5:0:0
6990.51:0:1
7000.41:0:0
701$round_mode = "odd"
702+5.23:-1:/5.2(?:0{5}\d+)?
703-5.23:-1:/-5.2(?:0{5}\d+)?
704+5.27:-1:/5.(?:3|29{5}\d+)
705-5.27:-1:/-5.(?:3|29{5}\d+)
706+5.25:-1:/5.(?:3|29{5}\d+)
707-5.25:-1:/-5.(?:3|29{5}\d+)
708+5.35:-1:/5.(?:3|29{5}\d+)
709-5.35:-1:/-5.(?:3|29{5}\d+)
710-0.0065:-1:0.0
711-0.0065:-2:/-0\.01|-1e-02
712-0.0065:-3:/-0\.007|-7e-03
713-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
714-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
7150.05:0:0
7160.5:0:1
7170.51:0:1
7180.41:0:0
719$round_mode = "even"
720+6.23:-1:/6.2(?:0{5}\d+)?
721-6.23:-1:/-6.2(?:0{5}\d+)?
722+6.27:-1:/6.(?:3|29{5}\d+)
723-6.27:-1:/-6.(?:3|29{5}\d+)
724+6.25:-1:/6.(?:2(?:0{5}\d+)?|29{5}\d+)
725-6.25:-1:/-6.(?:2(?:0{5}\d+)?|29{5}\d+)
726+6.35:-1:/6.(?:4|39{5}\d+|29{8}\d+)
727-6.35:-1:/-6.(?:4|39{5}\d+|29{8}\d+)
728-0.0065:-1:0.0
729-0.0065:-2:/-0\.01|-1e-02
730-0.0065:-3:/-0\.006|-7e-03
731-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
732-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
7330.05:0:0
7340.5:0:0
7350.51:0:1
7360.41:0:0
7370.01234567:-3:0.012
7380.01234567:-4:0.0123
7390.01234567:-5:0.01235
7400.01234567:-6:0.012346
7410.01234567:-7:0.0123457
7420.01234567:-8:0.01234567
7430.01234567:-9:0.012345670
7440.01234567:-12:0.012345670000
745&fcmp
746fcmpNaN:fcmpNaN:
747fcmpNaN:+0:
748+0:fcmpNaN:
749+0:+0:0
750-1:+0:-1
751+0:-1:1
752+1:+0:1
753+0:+1:-1
754-1:+1:-1
755+1:-1:1
756-1:-1:0
757+1:+1:0
758-1.1:0:-1
759+0:-1.1:1
760+1.1:+0:1
761+0:+1.1:-1
762+123:+123:0
763+123:+12:1
764+12:+123:-1
765-123:-123:0
766-123:-12:-1
767-12:-123:1
768+123:+124:-1
769+124:+123:1
770-123:-124:1
771-124:-123:-1
7720:0.01:-1
7730:0.0001:-1
7740:-0.0001:1
7750:-0.1:1
7760.1:0:1
7770.00001:0:1
778-0.0001:0:-1
779-0.1:0:-1
7800:0.0001234:-1
7810:-0.0001234:1
7820.0001234:0:1
783-0.0001234:0:-1
7840.0001:0.0005:-1
7850.0005:0.0001:1
7860.005:0.0001:1
7870.001:0.0005:1
7880.000001:0.0005:-1
7890.00000123:0.0005:-1
7900.00512:0.0001:1
7910.005:0.000112:1
7920.00123:0.0005:1
7931.5:2:-1
7942:1.5:1
7951.54321:234:-1
796234:1.54321:1
797# infinity
798-inf:5432112345:-1
799+inf:5432112345:1
800-inf:-5432112345:-1
801+inf:-5432112345:1
802-inf:54321.12345:-1
803+inf:54321.12345:1
804-inf:-54321.12345:-1
805+inf:-54321.12345:1
806+inf:+inf:0
807-inf:-inf:0
808+inf:-inf:1
809-inf:+inf:-1
810# return undef
811+inf:NaN:
812NaN:inf:
813-inf:NaN:
814NaN:-inf:
815&facmp
816fcmpNaN:fcmpNaN:
817fcmpNaN:+0:
818+0:fcmpNaN:
819+0:+0:0
820-1:+0:1
821+0:-1:-1
822+1:+0:1
823+0:+1:-1
824-1:+1:0
825+1:-1:0
826-1:-1:0
827+1:+1:0
828-1.1:0:1
829+0:-1.1:-1
830+1.1:+0:1
831+0:+1.1:-1
832+123:+123:0
833+123:+12:1
834+12:+123:-1
835-123:-123:0
836-123:-12:1
837-12:-123:-1
838+123:+124:-1
839+124:+123:1
840-123:-124:-1
841-124:-123:1
8420:0.01:-1
8430:0.0001:-1
8440:-0.0001:-1
8450:-0.1:-1
8460.1:0:1
8470.00001:0:1
848-0.0001:0:1
849-0.1:0:1
8500:0.0001234:-1
8510:-0.0001234:-1
8520.0001234:0:1
853-0.0001234:0:1
8540.0001:0.0005:-1
8550.0005:0.0001:1
8560.005:0.0001:1
8570.001:0.0005:1
8580.000001:0.0005:-1
8590.00000123:0.0005:-1
8600.00512:0.0001:1
8610.005:0.000112:1
8620.00123:0.0005:1
8631.5:2:-1
8642:1.5:1
8651.54321:234:-1
866234:1.54321:1
867# infinity
868-inf:5432112345:1
869+inf:5432112345:1
870-inf:-5432112345:1
871+inf:-5432112345:1
872-inf:54321.12345:1
873+inf:54321.12345:1
874-inf:-54321.12345:1
875+inf:-54321.12345:1
876+inf:+inf:0
877-inf:-inf:0
878+inf:-inf:0
879-inf:+inf:0
48b581a2 8805:inf:-1
881-1:inf:-1
8825:-inf:-1
883-1:-inf:-1
ee15d750 884# return undef
885+inf:facmpNaN:
886facmpNaN:inf:
887-inf:facmpNaN:
888facmpNaN:-inf:
889&fdec
890fdecNaN:NaN
891+inf:inf
892-inf:-inf
893+0:-1
894+1:0
895-1:-2
8961.23:0.23
897-1.23:-2.23
e745a66c 898100:99
899101:100
900-100:-101
901-99:-100
902-98:-99
90399:98
ee15d750 904&finc
905fincNaN:NaN
906+inf:inf
907-inf:-inf
908+0:1
909+1:2
910-1:0
9111.23:2.23
912-1.23:-0.23
e745a66c 913100:101
914-100:-99
915-99:-98
916-101:-100
91799:100
ee15d750 918&fadd
919abc:abc:NaN
920abc:+0:NaN
921+0:abc:NaN
13a12e00 922+inf:-inf:NaN
923-inf:+inf:NaN
ee15d750 924+inf:+inf:inf
925-inf:-inf:-inf
926baddNaN:+inf:NaN
927baddNaN:+inf:NaN
928+inf:baddNaN:NaN
929-inf:baddNaN:NaN
930+0:+0:0
931+1:+0:1
932+0:+1:1
933+1:+1:2
934-1:+0:-1
935+0:-1:-1
936-1:-1:-2
937-1:+1:0
938+1:-1:0
939+9:+1:10
940+99:+1:100
941+999:+1:1000
942+9999:+1:10000
943+99999:+1:100000
944+999999:+1:1000000
945+9999999:+1:10000000
946+99999999:+1:100000000
947+999999999:+1:1000000000
948+9999999999:+1:10000000000
949+99999999999:+1:100000000000
950+10:-1:9
951+100:-1:99
952+1000:-1:999
953+10000:-1:9999
954+100000:-1:99999
955+1000000:-1:999999
956+10000000:-1:9999999
957+100000000:-1:99999999
958+1000000000:-1:999999999
959+10000000000:-1:9999999999
960+123456789:+987654321:1111111110
961-123456789:+987654321:864197532
962-123456789:-987654321:-1111111110
963+123456789:-987654321:-864197532
9640.001234:0.0001234:0.0013574
965&fsub
966abc:abc:NaN
967abc:+0:NaN
968+0:abc:NaN
969+inf:-inf:inf
970-inf:+inf:-inf
13a12e00 971+inf:+inf:NaN
972-inf:-inf:NaN
ee15d750 973baddNaN:+inf:NaN
974baddNaN:+inf:NaN
975+inf:baddNaN:NaN
976-inf:baddNaN:NaN
977+0:+0:0
978+1:+0:1
979+0:+1:-1
980+1:+1:0
981-1:+0:-1
982+0:-1:1
983-1:-1:0
984-1:+1:-2
985+1:-1:2
986+9:+1:8
987+99:+1:98
988+999:+1:998
989+9999:+1:9998
990+99999:+1:99998
991+999999:+1:999998
992+9999999:+1:9999998
993+99999999:+1:99999998
994+999999999:+1:999999998
995+9999999999:+1:9999999998
996+99999999999:+1:99999999998
997+10:-1:11
998+100:-1:101
999+1000:-1:1001
1000+10000:-1:10001
1001+100000:-1:100001
1002+1000000:-1:1000001
1003+10000000:-1:10000001
1004+100000000:-1:100000001
1005+1000000000:-1:1000000001
1006+10000000000:-1:10000000001
1007+123456789:+987654321:-864197532
1008-123456789:+987654321:-1111111110
1009-123456789:-987654321:864197532
1010+123456789:-987654321:1111111110
1011&fmul
1012abc:abc:NaN
1013abc:+0:NaN
1014+0:abc:NaN
1015+inf:NaNmul:NaN
1016+inf:NaNmul:NaN
1017NaNmul:+inf:NaN
1018NaNmul:-inf:NaN
1019+inf:+inf:inf
1020+inf:-inf:-inf
1021+inf:-inf:-inf
1022+inf:+inf:inf
1023+inf:123.34:inf
1024+inf:-123.34:-inf
1025-inf:123.34:-inf
1026-inf:-123.34:inf
1027123.34:+inf:inf
1028-123.34:+inf:-inf
1029123.34:-inf:-inf
1030-123.34:-inf:inf
1031+0:+0:0
1032+0:+1:0
1033+1:+0:0
1034+0:-1:0
1035-1:+0:0
1036+123456789123456789:+0:0
1037+0:+123456789123456789:0
1038-1:-1:1
1039-1:+1:-1
1040+1:-1:-1
1041+1:+1:1
1042+2:+3:6
1043-2:+3:-6
1044+2:-3:-6
1045-2:-3:6
1046+111:+111:12321
1047+10101:+10101:102030201
1048+1001001:+1001001:1002003002001
1049+100010001:+100010001:10002000300020001
1050+10000100001:+10000100001:100002000030000200001
1051+11111111111:+9:99999999999
1052+22222222222:+9:199999999998
1053+33333333333:+9:299999999997
1054+44444444444:+9:399999999996
1055+55555555555:+9:499999999995
1056+66666666666:+9:599999999994
1057+77777777777:+9:699999999993
1058+88888888888:+9:799999999992
1059+99999999999:+9:899999999991
10606:120:720
106110:10000:100000
b3abae2a 1062&fdiv-list
10630:0:NaN,NaN
10640:1:0,0
10659:4:2.25,1
10669:5:1.8,4
ee15d750 1067&fdiv
1068$div_scale = 40; $round_mode = 'even'
1069abc:abc:NaN
1070abc:+1:abc:NaN
1071+1:abc:NaN
1072-1:abc:NaN
10730:abc:NaN
1074+0:+0:NaN
1075+0:+1:0
1076+1:+0:inf
1077+3214:+0:inf
1078+0:-1:0
1079-1:+0:-inf
1080-3214:+0:-inf
1081+1:+1:1
1082-1:-1:1
1083+1:-1:-1
1084-1:+1:-1
1085+1:+2:0.5
1086+2:+1:2
1087123:+inf:0
1088123:-inf:0
1089+10:+5:2
1090+100:+4:25
1091+1000:+8:125
1092+10000:+16:625
1093+10000:-16:-625
1094+999999999999:+9:111111111111
1095+999999999999:+99:10101010101
1096+999999999999:+999:1001001001
1097+999999999999:+9999:100010001
1098+999999999999999:+99999:10000100001
1099+1000000000:+9:111111111.1111111111111111111111111111111
1100+2000000000:+9:222222222.2222222222222222222222222222222
1101+3000000000:+9:333333333.3333333333333333333333333333333
1102+4000000000:+9:444444444.4444444444444444444444444444444
1103+5000000000:+9:555555555.5555555555555555555555555555556
1104+6000000000:+9:666666666.6666666666666666666666666666667
1105+7000000000:+9:777777777.7777777777777777777777777777778
1106+8000000000:+9:888888888.8888888888888888888888888888889
1107+9000000000:+9:1000000000
1108+35500000:+113:314159.2920353982300884955752212389380531
1109+71000000:+226:314159.2920353982300884955752212389380531
1110+106500000:+339:314159.2920353982300884955752212389380531
1111+1000000000:+3:333333333.3333333333333333333333333333333
11122:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447
394e6ffb 1113123456:1:123456
ee15d750 1114$div_scale = 20
1115+1000000000:+9:111111111.11111111111
1116+2000000000:+9:222222222.22222222222
1117+3000000000:+9:333333333.33333333333
1118+4000000000:+9:444444444.44444444444
1119+5000000000:+9:555555555.55555555556
1120+6000000000:+9:666666666.66666666667
1121+7000000000:+9:777777777.77777777778
1122+8000000000:+9:888888888.88888888889
1123+9000000000:+9:1000000000
11241:10:0.1
11251:100:0.01
11261:1000:0.001
11271:10000:0.0001
11281:504:0.001984126984126984127
11292:1.987654321:1.0062111801179738436
394e6ffb 1130123456789.123456789123456789123456789:1:123456789.12345678912
ee15d750 1131# the next two cases are the "old" behaviour, but are now (>v0.01) different
1132#+35500000:+113:314159.292035398230088
1133#+71000000:+226:314159.292035398230088
1134+35500000:+113:314159.29203539823009
1135+71000000:+226:314159.29203539823009
1136+106500000:+339:314159.29203539823009
1137+1000000000:+3:333333333.33333333333
1138$div_scale = 1
1139# round to accuracy 1 after bdiv
1140+124:+3:40
394e6ffb 1141123456789.1234:1:100000000
ee15d750 1142# reset scale for further tests
1143$div_scale = 40
1144&fmod
61f5c3f5 1145+9:4:1
1146+9:5:4
1147+9000:56:40
1148+56:9000:56
1149# inf handling, see table in doc
11500:inf:0
11510:-inf:0
11525:inf:5
11535:-inf:5
1154-5:inf:-5
1155-5:-inf:-5
1156inf:5:0
1157-inf:5:0
1158inf:-5:0
1159-inf:-5:0
11605:5:0
1161-5:-5:0
b3abae2a 1162inf:inf:NaN
1163-inf:-inf:NaN
1164-inf:inf:NaN
1165inf:-inf:NaN
61f5c3f5 11668:0:8
1167inf:0:inf
1168# exceptions to reminder rule
1169-inf:0:-inf
1170-8:0:-8
11710:0:NaN
1172abc:abc:NaN
1173abc:1:abc:NaN
11741:abc:NaN
11750:0:NaN
11760:1:0
11771:0:1
11780:-1:0
1179-1:0:-1
11801:1:0
1181-1:-1:0
11821:-1:0
1183-1:1:0
11841:2:1
11852:1:0
11861000000000:9:1
11872000000000:9:2
11883000000000:9:3
11894000000000:9:4
11905000000000:9:5
11916000000000:9:6
11927000000000:9:7
11938000000000:9:8
11949000000000:9:0
119535500000:113:33
119671000000:226:66
1197106500000:339:99
11981000000000:3:1
119910:5:0
1200100:4:0
12011000:8:0
120210000:16:0
1203999999999999:9:0
1204999999999999:99:0
1205999999999999:999:0
1206999999999999:9999:0
1207999999999999999:99999:0
1208-9:+5:1
1209+9:-5:-1
1210-9:-5:-4
1211-5:3:1
1212-2:3:1
12134:3:1
12141:3:1
1215-5:-3:-2
1216-2:-3:-2
12174:-3:-2
12181:-3:-2
12194095:4095:0
1220100041000510123:3:0
1221152403346:12345:4321
122287654321:87654321:0
1223# now some floating point tests
1224123:2.5:0.5
12251230:2.5:0
1226123.4:2.5:0.9
1227123e1:25:5
b3abae2a 1228&ffac
1229Nanfac:NaN
1230-1:NaN
b282a552 1231+inf:inf
091c87b1 1232-inf:NaN
b3abae2a 12330:1
12341:1
12352:2
12363:6
12374:24
12385:120
12396:720
124010:3628800
124111:39916800
124212:479001600
990fb837 1243&froot
1244# sqrt()
1245+0:2:0
1246+1:2:1
1247-1:2:NaN
1248# -$x ** (1/2) => -$y, but not in froot()
1249-123.456:2:NaN
1250+inf:2:inf
1251-inf:2:NaN
12522:2:1.41421356237309504880168872420969807857
1253-2:2:NaN
12544:2:2
12559:2:3
125616:2:4
1257100:2:10
1258123.456:2:11.11107555549866648462149404118219234119
125915241.38393:2:123.4559999756998444766131352122991626468
12601.44:2:1.2
126112:2:3.464101615137754587054892683011744733886
12620.49:2:0.7
12630.0049:2:0.07
1264# invalid ones
12651:NaN:NaN
1266-1:NaN:NaN
12670:NaN:NaN
1268-inf:NaN:NaN
1269+inf:NaN:NaN
1270NaN:0:NaN
1271NaN:2:NaN
1272NaN:inf:NaN
1273NaN:inf:NaN
127412:-inf:NaN
127512:inf:NaN
1276+0:0:NaN
1277+1:0:NaN
1278-1:0:NaN
1279-2:0:NaN
1280-123.45:0:NaN
1281+inf:0:NaN
128212:1:12
1283-12:1:NaN
12848:-1:NaN
1285-8:-1:NaN
1286# cubic root
12878:3:2
1288-8:3:NaN
1289# fourths root
129016:4:2
129181:4:3
3a427a11 1292# see t/bigroot() for more tests
ee15d750 1293&fsqrt
1294+0:0
1295-1:NaN
1296-2:NaN
1297-16:NaN
1298-123.45:NaN
1299nanfsqrt:NaN
1300+inf:inf
1301-inf:NaN
394e6ffb 13021:1
13032:1.41421356237309504880168872420969807857
13044:2
13059:3
130616:4
1307100:10
1308123.456:11.11107555549866648462149404118219234119
130915241.38393:123.4559999756998444766131352122991626468
13101.44:1.2
1311# sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4
13121.44E10:120000
13132e10:141421.356237309504880168872420969807857
b3abae2a 1314144e20:120000000000
61f5c3f5 1315# proved to be an endless loop under 7-9
131612:3.464101615137754587054892683011744733886
990fb837 13170.49:0.7
13180.0049:0.07
027dc388 1319&is_nan
1320123:0
1321abc:1
1322NaN:1
1323-123:0
1324&is_inf
1325+inf::1
1326-inf::1
1327abc::0
13281::0
1329NaN::0
1330-1::0
1331+inf:-:0
1332+inf:+:1
1333-inf:-:1
1334-inf:+:0
1335# it must be exactly /^[+-]inf$/
1336+infinity::0
1337-infinity::0
ee15d750 1338&is_odd
1339abc:0
13400:0
1341-1:1
1342-3:1
13431:1
13443:1
13451000001:1
13461000002:0
1347+inf:0
1348-inf:0
1349123.45:0
1350-123.45:0
13512:0
b3abae2a 1352&is_int
1353NaNis_int:0
13540:1
13551:1
13562:1
1357-2:1
1358-1:1
1359-inf:0
1360+inf:0
1361123.4567:0
1362-0.1:0
1363-0.002:0
ee15d750 1364&is_even
1365abc:0
13660:1
1367-1:0
1368-3:0
13691:0
13703:0
13711000001:0
13721000002:1
13732:1
1374+inf:0
1375-inf:0
1376123.456:0
1377-123.456:0
b3abae2a 13780.01:0
1379-0.01:0
1380120:1
13811200:1
1382-1200:1
ee15d750 1383&is_positive
13840:1
13851:1
1386-1:0
1387-123:0
1388NaN:0
1389-inf:0
1390+inf:1
1391&is_negative
13920:0
13931:0
1394-1:1
1395-123:1
1396NaN:0
1397-inf:1
1398+inf:0
1399&parts
14000:0 1
14011:1 0
1402123:123 0
1403-123:-123 0
1404-1200:-12 2
1405NaNparts:NaN NaN
1406+inf:inf inf
1407-inf:-inf inf
1408&exponent
14090:1
14101:0
1411123:0
1412-123:0
1413-1200:2
1414+inf:inf
1415-inf:inf
1416NaNexponent:NaN
1417&mantissa
14180:0
14191:1
1420123:123
1421-123:-123
1422-1200:-12
1423+inf:inf
1424-inf:-inf
1425NaNmantissa:NaN
1426&length
1427123:3
1428-123:3
14290:1
14301:1
143112345678901234567890:20
1432&is_zero
1433NaNzero:0
1434+inf:0
1435-inf:0
14360:1
1437-1:0
14381:0
1439&is_one
1440NaNone:0
1441+inf:0
1442-inf:0
14430:0
14442:0
14451:1
1446-1:0
1447-2:0
027dc388 1448&ffloor
ee15d750 14490:0
1450abc:NaN
1451+inf:inf
1452-inf:-inf
14531:1
1454-51:-51
1455-51.2:-52
145612.2:12
990fb837 14570.12345:0
14580.123456:0
14590.1234567:0
14600.12345678:0
14610.123456789:0
027dc388 1462&fceil
ee15d750 14630:0
1464abc:NaN
1465+inf:inf
1466-inf:-inf
14671:1
1468-51:-51
1469-51.2:-51
147012.2:13