Upgrade to Encode 0.97, from Dan Kogai.
[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
ee15d750 5while (<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]');";
027dc388 37 } elsif ($f eq "is_inf") {
38 $try .= "\$x->is_inf('$args[1]');";
ee15d750 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();';
ee15d750 44 } elsif ($f eq "parts") {
48b581a2 45 # ->bstr() to see if an object is returned
ee15d750 46 $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();';
47 $try .= '"$a $b";';
ee15d750 48 } elsif ($f eq "exponent") {
48b581a2 49 # ->bstr() to see if an object is returned
ee15d750 50 $try .= '$x->exponent()->bstr();';
51 } elsif ($f eq "mantissa") {
48b581a2 52 # ->bstr() to see if an object is returned
ee15d750 53 $try .= '$x->mantissa()->bstr();';
027dc388 54 } elsif ($f eq "numify") {
55 $try .= "\$x->numify();";
56 } elsif ($f eq "length") {
57 $try .= "\$x->length();";
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 "as_number") {
65 $try .= '$x->as_number();';
ee15d750 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();";
b3abae2a 76 } elsif ($f eq "flog") {
77 $try .= "$setup; \$x->flog();";
78 } elsif ($f eq "ffac") {
79 $try .= "$setup; \$x->ffac();";
ee15d750 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;";
b3abae2a 98 } elsif ($f eq "fdiv-list") {
99 $try .= "$setup; join(',',\$x->fdiv(\$y));";
394e6ffb 100 } elsif ($f eq "frsft") {
101 $try .= '$x >> $y;';
102 } elsif ($f eq "flsft") {
103 $try .= '$x << $y;';
ee15d750 104 } elsif ($f eq "fmod") {
105 $try .= '$x % $y;';
106 } else { warn "Unknown op '$f'"; }
107 }
e745a66c 108 # print "# Trying: '$try'\n";
ee15d750 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 {
027dc388 133 # float numbers are normalized (for now), so mantissa shouldn't have
134 # trailing zeros
ee15d750 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
394e6ffb 144# check whether $class->new( Math::BigInt->new()) destroys it
145# ($y == 12 in this case)
ee15d750 146$x = Math::BigInt->new(1200); $y = $class->new($x);
147ok ($y,1200); ok ($x,1200);
148
149###############################################################################
b3abae2a 150# zero,inf,one,nan
ee15d750 151
394e6ffb 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});
61f5c3f5 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
b3abae2a 171${${class}.'::accuracy'} = 4; $x = $class->new(12); $x->fsqrt(3); ok ($x,'NaN');
61f5c3f5 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
394e6ffb 176
13a12e00 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;
182ok ($ans,"$class 4 5");
183
394e6ffb 1841; # all done
ee15d750 185
186###############################################################################
187# Perl 5.005 does not like ok ($x,undef)
188
189sub 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__
b3abae2a 198$div_scale = 40;
199&flog
2000:NaN
201-1:NaN
202-2:NaN
2031:0
204# this is too slow for the testsuite
79c55733 205#2:0.6931471805599453094172321214581765680755
b3abae2a 206#2.718281828:0.9999999998311266953289851340574956564911
207#$div_scale = 20;
208#2.718281828:0.99999999983112669533
b3abae2a 209# too slow, too (or hangs?)
210#123:4.8112184355
79c55733 211$div_scale = 14;
b3abae2a 212#10:0:2.302585092994
61f5c3f5 213#1000:0:6.90775527898214
214#100:0:4.60517018598809
79c55733 2152:0:0.69314718055995
61f5c3f5 216#3.1415:0:1.14470039286086
217#12345:0:9.42100640177928
218#0.001:0:-6.90775527898214
b3abae2a 219# reset for further tests
220$div_scale = 40;
79c55733 2211:0
394e6ffb 222&frsft
b3abae2a 223NaNfrsft:2:NaN
394e6ffb 2240:2:0
2251:1:0.5
2262:1:1
2274:1:2
228123:1:61.5
22932:3:4
230&flsft
b3abae2a 231NaNflsft:0:NaN
394e6ffb 2322:1:4
2334:3:32
2345:3:40
2351:2:4
2360:5:0
ee15d750 237&fnorm
2381:1
239-0:0
240fnormNaN:NaN
241+inf:inf
242-inf:-inf
243123:123
244-123.4567:-123.4567
027dc388 245# invalid inputs
2461__2:NaN
2471E1__2:NaN
24811__2E2:NaN
249#1.E3:NaN
250.2E-3.:NaN
251#1e3e4:NaN
252.2E2:20
ee15d750 253&as_number
2540:0
2551:1
2561.2:1
2572.345:2
258-2:-2
259-123.456:-123
260-200:-200
261&finf
2621:+:inf
2632:-:-inf
2643:abc:inf
265&numify
2660:0e+1
267+1:1e+0
2681234:1234e+0
269NaN:NaN
270+inf:inf
271-inf:-inf
272&fnan
273abc:NaN
2742:NaN
275-2:NaN
2760:NaN
277&fone
2782:+:1
279-2:-:-1
280-2:+:1
2812:-:-1
2820::1
283-2::1
284abc::1
2852:abc:1
286&fsstr
287+inf:inf
288-inf:-inf
289abcfsstr:NaN
2901234.567:1234567e-3
291&fstr
292+inf:::inf
293-inf:::-inf
294abcfstr:::NaN
2951234.567:9::1234.56700
2961234.567::-6:1234.567000
29712345:5::12345
2980.001234:6::0.00123400
2990.001234::-8:0.00123400
3000:4::0
3010::-4:0.0000
302&fnorm
303inf:inf
304+inf:inf
305-inf:-inf
306+infinity:NaN
307+-inf:NaN
308abc:NaN
309 1 a:NaN
3101bcd2:NaN
31111111b:NaN
312+1z:NaN
313-1z:NaN
3140:0
315+0:0
316+00:0
317+0_0_0:0
318000000_0000000_00000:0
319-0:0
320-0000:0
321+1:1
322+01:1
323+001:1
324+00000100000:100000
325123456789:123456789
326-1:-1
327-01:-1
328-001:-1
329-123456789:-123456789
330-00000100000:-100000
331123.456a:NaN
332123.456:123.456
3330.01:0.01
334.002:0.002
335+.2:0.2
336-0.0003:-0.0003
337-.0000000004:-0.0000000004
338123456E2:12345600
339123456E-2:1234.56
340-123456E2:-12345600
341-123456E-2:-1234.56
3421e1:10
3432e-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
3552:2:4
3561:2:1
3571:3:1
358-1:2:1
359-1:3:-1
360123.456:2:15241.383936
3612:-2:0.25
3622:-3:0.125
363128:-2:0.00006103515625
364abc:123.456:NaN
365123.456:abc:NaN
366+inf:123.45:inf
367-inf:123.45:-inf
368+inf:-123.45:inf
369-inf:-123.45:-inf
79c55733 370# 2 ** 0.5 == sqrt(2)
371# 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0)
3722:0.5:1.41421356237309504880168872420969807857
3732:0.2:1.148698354997035006798626946777927589444
ee15d750 374&fneg
375fnegNaN: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
386fabsNaN: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
4000:5:0
401NaNfround: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
4590:5:0
460NaNffround: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
4880.05:0:0
4890.5:0:0
4900.51:0:0
4910.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
5060.05:0:0
5070.5:0:0
5080.51:0:1
5090.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
5240.05:0:0
5250.5:0:1
5260.51:0:1
5270.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
5420.05:0:0
5430.5:0:0
5440.51:0:1
5450.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
5600.05:0:0
5610.5:0:1
5620.51:0:1
5630.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
5780.05:0:0
5790.5:0:0
5800.51:0:1
5810.41:0:0
5820.01234567:-3:0.012
5830.01234567:-4:0.0123
5840.01234567:-5:0.01235
5850.01234567:-6:0.012346
5860.01234567:-7:0.0123457
5870.01234567:-8:0.01234567
5880.01234567:-9:0.012345670
5890.01234567:-12:0.012345670000
590&fcmp
591fcmpNaN:fcmpNaN:
592fcmpNaN:+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
6170:0.01:-1
6180:0.0001:-1
6190:-0.0001:1
6200:-0.1:1
6210.1:0:1
6220.00001:0:1
623-0.0001:0:-1
624-0.1:0:-1
6250:0.0001234:-1
6260:-0.0001234:1
6270.0001234:0:1
628-0.0001234:0:-1
6290.0001:0.0005:-1
6300.0005:0.0001:1
6310.005:0.0001:1
6320.001:0.0005:1
6330.000001:0.0005:-1
6340.00000123:0.0005:-1
6350.00512:0.0001:1
6360.005:0.000112:1
6370.00123:0.0005:1
6381.5:2:-1
6392:1.5:1
6401.54321:234:-1
641234: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:
657NaN:inf:
658-inf:NaN:
659NaN:-inf:
660&facmp
661fcmpNaN:fcmpNaN:
662fcmpNaN:+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
6870:0.01:-1
6880:0.0001:-1
6890:-0.0001:-1
6900:-0.1:-1
6910.1:0:1
6920.00001:0:1
693-0.0001:0:1
694-0.1:0:1
6950:0.0001234:-1
6960:-0.0001234:-1
6970.0001234:0:1
698-0.0001234:0:1
6990.0001:0.0005:-1
7000.0005:0.0001:1
7010.005:0.0001:1
7020.001:0.0005:1
7030.000001:0.0005:-1
7040.00000123:0.0005:-1
7050.00512:0.0001:1
7060.005:0.000112:1
7070.00123:0.0005:1
7081.5:2:-1
7092:1.5:1
7101.54321:234:-1
711234: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
48b581a2 7255:inf:-1
726-1:inf:-1
7275:-inf:-1
728-1:-inf:-1
ee15d750 729# return undef
730+inf:facmpNaN:
731facmpNaN:inf:
732-inf:facmpNaN:
733facmpNaN:-inf:
734&fdec
735fdecNaN:NaN
736+inf:inf
737-inf:-inf
738+0:-1
739+1:0
740-1:-2
7411.23:0.23
742-1.23:-2.23
e745a66c 743100:99
744101:100
745-100:-101
746-99:-100
747-98:-99
74899:98
ee15d750 749&finc
750fincNaN:NaN
751+inf:inf
752-inf:-inf
753+0:1
754+1:2
755-1:0
7561.23:2.23
757-1.23:-0.23
e745a66c 758100:101
759-100:-99
760-99:-98
761-101:-100
76299:100
ee15d750 763&fadd
764abc:abc:NaN
765abc:+0:NaN
766+0:abc:NaN
13a12e00 767+inf:-inf:NaN
768-inf:+inf:NaN
ee15d750 769+inf:+inf:inf
770-inf:-inf:-inf
771baddNaN:+inf:NaN
772baddNaN:+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
8090.001234:0.0001234:0.0013574
810&fsub
811abc:abc:NaN
812abc:+0:NaN
813+0:abc:NaN
814+inf:-inf:inf
815-inf:+inf:-inf
13a12e00 816+inf:+inf:NaN
817-inf:-inf:NaN
ee15d750 818baddNaN:+inf:NaN
819baddNaN:+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
857abc:abc:NaN
858abc:+0:NaN
859+0:abc:NaN
860+inf:NaNmul:NaN
861+inf:NaNmul:NaN
862NaNmul:+inf:NaN
863NaNmul:-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
872123.34:+inf:inf
873-123.34:+inf:-inf
874123.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
9056:120:720
90610:10000:100000
b3abae2a 907&fdiv-list
9080:0:NaN,NaN
9090:1:0,0
9109:4:2.25,1
9119:5:1.8,4
ee15d750 912&fdiv
913$div_scale = 40; $round_mode = 'even'
914abc:abc:NaN
915abc:+1:abc:NaN
916+1:abc:NaN
917-1:abc:NaN
9180: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
932123:+inf:0
933123:-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
9572:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447
394e6ffb 958123456:1:123456
ee15d750 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
9691:10:0.1
9701:100:0.01
9711:1000:0.001
9721:10000:0.0001
9731:504:0.001984126984126984127
9742:1.987654321:1.0062111801179738436
394e6ffb 975123456789.123456789123456789123456789:1:123456789.12345678912
ee15d750 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
394e6ffb 986123456789.1234:1:100000000
ee15d750 987# reset scale for further tests
988$div_scale = 40
989&fmod
61f5c3f5 990+9:4:1
991+9:5:4
992+9000:56:40
993+56:9000:56
994# inf handling, see table in doc
9950:inf:0
9960:-inf:0
9975:inf:5
9985:-inf:5
999-5:inf:-5
1000-5:-inf:-5
1001inf:5:0
1002-inf:5:0
1003inf:-5:0
1004-inf:-5:0
10055:5:0
1006-5:-5:0
b3abae2a 1007inf:inf:NaN
1008-inf:-inf:NaN
1009-inf:inf:NaN
1010inf:-inf:NaN
61f5c3f5 10118:0:8
1012inf:0:inf
1013# exceptions to reminder rule
1014-inf:0:-inf
1015-8:0:-8
10160:0:NaN
1017abc:abc:NaN
1018abc:1:abc:NaN
10191:abc:NaN
10200:0:NaN
10210:1:0
10221:0:1
10230:-1:0
1024-1:0:-1
10251:1:0
1026-1:-1:0
10271:-1:0
1028-1:1:0
10291:2:1
10302:1:0
10311000000000:9:1
10322000000000:9:2
10333000000000:9:3
10344000000000:9:4
10355000000000:9:5
10366000000000:9:6
10377000000000:9:7
10388000000000:9:8
10399000000000:9:0
104035500000:113:33
104171000000:226:66
1042106500000:339:99
10431000000000:3:1
104410:5:0
1045100:4:0
10461000:8:0
104710000:16:0
1048999999999999:9:0
1049999999999999:99:0
1050999999999999:999:0
1051999999999999:9999:0
1052999999999999999:99999:0
1053-9:+5:1
1054+9:-5:-1
1055-9:-5:-4
1056-5:3:1
1057-2:3:1
10584:3:1
10591:3:1
1060-5:-3:-2
1061-2:-3:-2
10624:-3:-2
10631:-3:-2
10644095:4095:0
1065100041000510123:3:0
1066152403346:12345:4321
106787654321:87654321:0
1068# now some floating point tests
1069123:2.5:0.5
10701230:2.5:0
1071123.4:2.5:0.9
1072123e1:25:5
b3abae2a 1073&ffac
1074Nanfac:NaN
1075-1:NaN
10760:1
10771:1
10782:2
10793:6
10804:24
10815:120
10826:720
108310:3628800
108411:39916800
108512:479001600
ee15d750 1086&fsqrt
1087+0:0
1088-1:NaN
1089-2:NaN
1090-16:NaN
1091-123.45:NaN
1092nanfsqrt:NaN
1093+inf:inf
1094-inf:NaN
394e6ffb 10951:1
10962:1.41421356237309504880168872420969807857
10974:2
10989:3
109916:4
1100100:10
1101123.456:11.11107555549866648462149404118219234119
110215241.38393:123.4559999756998444766131352122991626468
11031.44:1.2
1104# sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4
11051.44E10:120000
11062e10:141421.356237309504880168872420969807857
b3abae2a 1107144e20:120000000000
61f5c3f5 1108# proved to be an endless loop under 7-9
110912:3.464101615137754587054892683011744733886
027dc388 1110&is_nan
1111123:0
1112abc:1
1113NaN:1
1114-123:0
1115&is_inf
1116+inf::1
1117-inf::1
1118abc::0
11191::0
1120NaN::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
ee15d750 1129&is_odd
1130abc:0
11310:0
1132-1:1
1133-3:1
11341:1
11353:1
11361000001:1
11371000002:0
1138+inf:0
1139-inf:0
1140123.45:0
1141-123.45:0
11422:0
b3abae2a 1143&is_int
1144NaNis_int:0
11450:1
11461:1
11472:1
1148-2:1
1149-1:1
1150-inf:0
1151+inf:0
1152123.4567:0
1153-0.1:0
1154-0.002:0
ee15d750 1155&is_even
1156abc:0
11570:1
1158-1:0
1159-3:0
11601:0
11613:0
11621000001:0
11631000002:1
11642:1
1165+inf:0
1166-inf:0
1167123.456:0
1168-123.456:0
b3abae2a 11690.01:0
1170-0.01:0
1171120:1
11721200:1
1173-1200:1
ee15d750 1174&is_positive
11750:1
11761:1
1177-1:0
1178-123:0
1179NaN:0
1180-inf:0
1181+inf:1
1182&is_negative
11830:0
11841:0
1185-1:1
1186-123:1
1187NaN:0
1188-inf:1
1189+inf:0
1190&parts
11910:0 1
11921:1 0
1193123:123 0
1194-123:-123 0
1195-1200:-12 2
1196NaNparts:NaN NaN
1197+inf:inf inf
1198-inf:-inf inf
1199&exponent
12000:1
12011:0
1202123:0
1203-123:0
1204-1200:2
1205+inf:inf
1206-inf:inf
1207NaNexponent:NaN
1208&mantissa
12090:0
12101:1
1211123:123
1212-123:-123
1213-1200:-12
1214+inf:inf
1215-inf:-inf
1216NaNmantissa:NaN
1217&length
1218123:3
1219-123:3
12200:1
12211:1
122212345678901234567890:20
1223&is_zero
1224NaNzero:0
1225+inf:0
1226-inf:0
12270:1
1228-1:0
12291:0
1230&is_one
1231NaNone:0
1232+inf:0
1233-inf:0
12340:0
12352:0
12361:1
1237-1:0
1238-2:0
027dc388 1239&ffloor
ee15d750 12400:0
1241abc:NaN
1242+inf:inf
1243-inf:-inf
12441:1
1245-51:-51
1246-51.2:-52
124712.2:12
027dc388 1248&fceil
ee15d750 12490:0
1250abc:NaN
1251+inf:inf
1252-inf:-inf
12531:1
1254-51:-51
1255-51.2:-51
125612.2:13