Upgrade to Math::BigInt 1.48.
[p5sagit/p5-mst-13.2.git] / lib / Math / BigInt / t / bigfltpm.inc
CommitLineData
ee15d750 1#include this file into another test for subclass testing...
2while (<DATA>)
3 {
4 chop;
5 $_ =~ s/#.*$//; # remove comments
6 $_ =~ s/\s+$//; # trailing spaces
7 next if /^$/; # skip empty lines & comments
8 if (s/^&//)
9 {
10 $f = $_;
11 }
12 elsif (/^\$/)
13 {
14 $setup = $_; $setup =~ s/\$/\$${class}::/g; # round_mode, div_scale
15 #print "\$setup== $setup\n";
16 }
17 else
18 {
19 if (m|^(.*?):(/.+)$|)
20 {
21 $ans = $2;
22 @args = split(/:/,$1,99);
23 }
24 else
25 {
26 @args = split(/:/,$_,99); $ans = pop(@args);
27 }
28 $try = "\$x = new $class \"$args[0]\";";
29 if ($f eq "fnorm")
30 {
31 $try .= "\$x;";
32 } elsif ($f eq "finf") {
33 $try .= "\$x->finf('$args[1]');";
027dc388 34 } elsif ($f eq "is_inf") {
35 $try .= "\$x->is_inf('$args[1]');";
ee15d750 36 } elsif ($f eq "fone") {
37 $try .= "\$x->bone('$args[1]');";
38 } elsif ($f eq "fstr") {
39 $try .= "\$x->accuracy($args[1]); \$x->precision($args[2]);";
40 $try .= '$x->fstr();';
ee15d750 41 } elsif ($f eq "parts") {
48b581a2 42 # ->bstr() to see if an object is returned
ee15d750 43 $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();';
44 $try .= '"$a $b";';
ee15d750 45 } elsif ($f eq "exponent") {
48b581a2 46 # ->bstr() to see if an object is returned
ee15d750 47 $try .= '$x->exponent()->bstr();';
48 } elsif ($f eq "mantissa") {
48b581a2 49 # ->bstr() to see if an object is returned
ee15d750 50 $try .= '$x->mantissa()->bstr();';
027dc388 51 } elsif ($f eq "numify") {
52 $try .= "\$x->numify();";
53 } elsif ($f eq "length") {
54 $try .= "\$x->length();";
55 # some unary ops (test the bxxx form, since that is done by AUTOLOAD)
56 } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|abs)$/) {
394e6ffb 57 $try .= "\$x->f$1();";
027dc388 58 # some is_xxx test function
59 } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan)$/) {
60 $try .= "\$x->$f();";
ee15d750 61 } elsif ($f eq "as_number") {
62 $try .= '$x->as_number();';
ee15d750 63 } elsif ($f eq "finc") {
64 $try .= '++$x;';
65 } elsif ($f eq "fdec") {
66 $try .= '--$x;';
67 }elsif ($f eq "fround") {
68 $try .= "$setup; \$x->fround($args[1]);";
69 } elsif ($f eq "ffround") {
70 $try .= "$setup; \$x->ffround($args[1]);";
71 } elsif ($f eq "fsqrt") {
72 $try .= "$setup; \$x->fsqrt();";
73 }
74 else
75 {
76 $try .= "\$y = new $class \"$args[1]\";";
77 if ($f eq "fcmp") {
78 $try .= '$x <=> $y;';
79 } elsif ($f eq "facmp") {
80 $try .= '$x->facmp($y);';
81 } elsif ($f eq "fpow") {
82 $try .= '$x ** $y;';
83 } elsif ($f eq "fadd") {
84 $try .= '$x + $y;';
85 } elsif ($f eq "fsub") {
86 $try .= '$x - $y;';
87 } elsif ($f eq "fmul") {
88 $try .= '$x * $y;';
89 } elsif ($f eq "fdiv") {
90 $try .= "$setup; \$x / \$y;";
394e6ffb 91 } elsif ($f eq "frsft") {
92 $try .= '$x >> $y;';
93 } elsif ($f eq "flsft") {
94 $try .= '$x << $y;';
ee15d750 95 } elsif ($f eq "fmod") {
96 $try .= '$x % $y;';
97 } else { warn "Unknown op '$f'"; }
98 }
e745a66c 99 # print "# Trying: '$try'\n";
ee15d750 100 $ans1 = eval $try;
101 if ($ans =~ m|^/(.*)$|)
102 {
103 my $pat = $1;
104 if ($ans1 =~ /$pat/)
105 {
106 ok (1,1);
107 }
108 else
109 {
110 print "# '$try' expected: /$pat/ got: '$ans1'\n" if !ok(1,0);
111 }
112 }
113 else
114 {
115 if ($ans eq "")
116 {
117 ok_undef ($ans1);
118 }
119 else
120 {
121 print "# Tried: '$try'\n" if !ok ($ans1, $ans);
122 if (ref($ans1) eq "$class")
123 {
027dc388 124 # float numbers are normalized (for now), so mantissa shouldn't have
125 # trailing zeros
ee15d750 126 #print $ans1->_trailing_zeros(),"\n";
127 print "# Has trailing zeros after '$try'\n"
128 if !ok ($ans1->{_m}->_trailing_zeros(), 0);
129 }
130 }
131 } # end pattern or string
132 }
133 } # end while
134
394e6ffb 135# check whether $class->new( Math::BigInt->new()) destroys it
136# ($y == 12 in this case)
ee15d750 137$x = Math::BigInt->new(1200); $y = $class->new($x);
138ok ($y,1200); ok ($x,1200);
139
140###############################################################################
141# fdiv() in list context
142$x = $class->bzero(); ($x,$y) = $x->fdiv(0);
143ok ($x,'NaN'); ok ($y,'NaN');
144
145# fdiv() in list context
146$x = $class->bzero(); ($x,$y) = $x->fdiv(1);
147ok ($x,0); ok ($y,0);
148
394e6ffb 149$x = $class->new(2); $x->fzero(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
150$x = $class->new(2); $x->finf(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
151$x = $class->new(2); $x->fone(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
152$x = $class->new(2); $x->fnan(); ok_undef ($x->{_a}); ok_undef ($x->{_p});
153
1541; # all done
ee15d750 155
156###############################################################################
157# Perl 5.005 does not like ok ($x,undef)
158
159sub ok_undef
160 {
161 my $x = shift;
162
163 ok (1,1) and return if !defined $x;
164 ok ($x,'undef');
165 }
166
167__DATA__
394e6ffb 168&frsft
169#NaNfrsft:NaN
1700:2:0
1711:1:0.5
1722:1:1
1734:1:2
174123:1:61.5
17532:3:4
176&flsft
177#NaNflsft:NaN
1782:1:4
1794:3:32
1805:3:40
1811:2:4
1820:5:0
ee15d750 183&fnorm
1841:1
185-0:0
186fnormNaN:NaN
187+inf:inf
188-inf:-inf
189123:123
190-123.4567:-123.4567
027dc388 191# invalid inputs
1921__2:NaN
1931E1__2:NaN
19411__2E2:NaN
195#1.E3:NaN
196.2E-3.:NaN
197#1e3e4:NaN
198.2E2:20
ee15d750 199&as_number
2000:0
2011:1
2021.2:1
2032.345:2
204-2:-2
205-123.456:-123
206-200:-200
207&finf
2081:+:inf
2092:-:-inf
2103:abc:inf
211&numify
2120:0e+1
213+1:1e+0
2141234:1234e+0
215NaN:NaN
216+inf:inf
217-inf:-inf
218&fnan
219abc:NaN
2202:NaN
221-2:NaN
2220:NaN
223&fone
2242:+:1
225-2:-:-1
226-2:+:1
2272:-:-1
2280::1
229-2::1
230abc::1
2312:abc:1
232&fsstr
233+inf:inf
234-inf:-inf
235abcfsstr:NaN
2361234.567:1234567e-3
237&fstr
238+inf:::inf
239-inf:::-inf
240abcfstr:::NaN
2411234.567:9::1234.56700
2421234.567::-6:1234.567000
24312345:5::12345
2440.001234:6::0.00123400
2450.001234::-8:0.00123400
2460:4::0
2470::-4:0.0000
248&fnorm
249inf:inf
250+inf:inf
251-inf:-inf
252+infinity:NaN
253+-inf:NaN
254abc:NaN
255 1 a:NaN
2561bcd2:NaN
25711111b:NaN
258+1z:NaN
259-1z:NaN
2600:0
261+0:0
262+00:0
263+0_0_0:0
264000000_0000000_00000:0
265-0:0
266-0000:0
267+1:1
268+01:1
269+001:1
270+00000100000:100000
271123456789:123456789
272-1:-1
273-01:-1
274-001:-1
275-123456789:-123456789
276-00000100000:-100000
277123.456a:NaN
278123.456:123.456
2790.01:0.01
280.002:0.002
281+.2:0.2
282-0.0003:-0.0003
283-.0000000004:-0.0000000004
284123456E2:12345600
285123456E-2:1234.56
286-123456E2:-12345600
287-123456E-2:-1234.56
2881e1:10
2892e-11:0.00000000002
290# excercise _split
291 .02e-1:0.002
292 000001:1
293 -00001:-1
294 -1:-1
295 000.01:0.01
296 -000.0023:-0.0023
297 1.1e1:11
298-3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
299-4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004
300&fpow
3012:2:4
3021:2:1
3031:3:1
304-1:2:1
305-1:3:-1
306123.456:2:15241.383936
3072:-2:0.25
3082:-3:0.125
309128:-2:0.00006103515625
310abc:123.456:NaN
311123.456:abc:NaN
312+inf:123.45:inf
313-inf:123.45:-inf
314+inf:-123.45:inf
315-inf:-123.45:-inf
316&fneg
317fnegNaN:NaN
318+inf:-inf
319-inf:inf
320+0:0
321+1:-1
322-1:1
323+123456789:-123456789
324-123456789:123456789
325+123.456789:-123.456789
326-123456.789:123456.789
327&fabs
328fabsNaN:NaN
329+inf:inf
330-inf:inf
331+0:0
332+1:1
333-1:1
334+123456789:123456789
335-123456789:123456789
336+123.456789:123.456789
337-123456.789:123456.789
338&fround
339$round_mode = "trunc"
340+inf:5:inf
341-inf:5:-inf
3420:5:0
343NaNfround:5:NaN
344+10123456789:5:10123000000
345-10123456789:5:-10123000000
346+10123456789.123:5:10123000000
347-10123456789.123:5:-10123000000
348+10123456789:9:10123456700
349-10123456789:9:-10123456700
350+101234500:6:101234000
351-101234500:6:-101234000
352$round_mode = "zero"
353+20123456789:5:20123000000
354-20123456789:5:-20123000000
355+20123456789.123:5:20123000000
356-20123456789.123:5:-20123000000
357+20123456789:9:20123456800
358-20123456789:9:-20123456800
359+201234500:6:201234000
360-201234500:6:-201234000
361$round_mode = "+inf"
362+30123456789:5:30123000000
363-30123456789:5:-30123000000
364+30123456789.123:5:30123000000
365-30123456789.123:5:-30123000000
366+30123456789:9:30123456800
367-30123456789:9:-30123456800
368+301234500:6:301235000
369-301234500:6:-301234000
370$round_mode = "-inf"
371+40123456789:5:40123000000
372-40123456789:5:-40123000000
373+40123456789.123:5:40123000000
374-40123456789.123:5:-40123000000
375+40123456789:9:40123456800
376-40123456789:9:-40123456800
377+401234500:6:401234000
378-401234500:6:-401235000
379$round_mode = "odd"
380+50123456789:5:50123000000
381-50123456789:5:-50123000000
382+50123456789.123:5:50123000000
383-50123456789.123:5:-50123000000
384+50123456789:9:50123456800
385-50123456789:9:-50123456800
386+501234500:6:501235000
387-501234500:6:-501235000
388$round_mode = "even"
389+60123456789:5:60123000000
390-60123456789:5:-60123000000
391+60123456789:9:60123456800
392-60123456789:9:-60123456800
393+601234500:6:601234000
394-601234500:6:-601234000
395+60123456789.0123:5:60123000000
396-60123456789.0123:5:-60123000000
397&ffround
398$round_mode = "trunc"
399+inf:5:inf
400-inf:5:-inf
4010:5:0
402NaNffround:5:NaN
403+1.23:-1:1.2
404+1.234:-1:1.2
405+1.2345:-1:1.2
406+1.23:-2:1.23
407+1.234:-2:1.23
408+1.2345:-2:1.23
409+1.23:-3:1.230
410+1.234:-3:1.234
411+1.2345:-3:1.234
412-1.23:-1:-1.2
413+1.27:-1:1.2
414-1.27:-1:-1.2
415+1.25:-1:1.2
416-1.25:-1:-1.2
417+1.35:-1:1.3
418-1.35:-1:-1.3
419-0.0061234567890:-1:0.0
420-0.0061:-1:0.0
421-0.00612:-1:0.0
422-0.00612:-2:0.00
423-0.006:-1:0.0
424-0.006:-2:0.00
425-0.0006:-2:0.00
426-0.0006:-3:0.000
427-0.0065:-3:/-0\.006|-6e-03
428-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
429-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
4300.05:0:0
4310.5:0:0
4320.51:0:0
4330.41:0:0
434$round_mode = "zero"
435+2.23:-1:/2.2(?:0{5}\d+)?
436-2.23:-1:/-2.2(?:0{5}\d+)?
437+2.27:-1:/2.(?:3|29{5}\d+)
438-2.27:-1:/-2.(?:3|29{5}\d+)
439+2.25:-1:/2.2(?:0{5}\d+)?
440-2.25:-1:/-2.2(?:0{5}\d+)?
441+2.35:-1:/2.(?:3|29{5}\d+)
442-2.35:-1:/-2.(?:3|29{5}\d+)
443-0.0065:-1:0.0
444-0.0065:-2:/-0\.01|-1e-02
445-0.0065:-3:/-0\.006|-6e-03
446-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
447-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
4480.05:0:0
4490.5:0:0
4500.51:0:1
4510.41:0:0
452$round_mode = "+inf"
453+3.23:-1:/3.2(?:0{5}\d+)?
454-3.23:-1:/-3.2(?:0{5}\d+)?
455+3.27:-1:/3.(?:3|29{5}\d+)
456-3.27:-1:/-3.(?:3|29{5}\d+)
457+3.25:-1:/3.(?:3|29{5}\d+)
458-3.25:-1:/-3.2(?:0{5}\d+)?
459+3.35:-1:/3.(?:4|39{5}\d+)
460-3.35:-1:/-3.(?:3|29{5}\d+)
461-0.0065:-1:0.0
462-0.0065:-2:/-0\.01|-1e-02
463-0.0065:-3:/-0\.006|-6e-03
464-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
465-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
4660.05:0:0
4670.5:0:1
4680.51:0:1
4690.41:0:0
470$round_mode = "-inf"
471+4.23:-1:/4.2(?:0{5}\d+)?
472-4.23:-1:/-4.2(?:0{5}\d+)?
473+4.27:-1:/4.(?:3|29{5}\d+)
474-4.27:-1:/-4.(?:3|29{5}\d+)
475+4.25:-1:/4.2(?:0{5}\d+)?
476-4.25:-1:/-4.(?:3|29{5}\d+)
477+4.35:-1:/4.(?:3|29{5}\d+)
478-4.35:-1:/-4.(?:4|39{5}\d+)
479-0.0065:-1:0.0
480-0.0065:-2:/-0\.01|-1e-02
481-0.0065:-3:/-0\.007|-7e-03
482-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
483-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
4840.05:0:0
4850.5:0:0
4860.51:0:1
4870.41:0:0
488$round_mode = "odd"
489+5.23:-1:/5.2(?:0{5}\d+)?
490-5.23:-1:/-5.2(?:0{5}\d+)?
491+5.27:-1:/5.(?:3|29{5}\d+)
492-5.27:-1:/-5.(?:3|29{5}\d+)
493+5.25:-1:/5.(?:3|29{5}\d+)
494-5.25:-1:/-5.(?:3|29{5}\d+)
495+5.35:-1:/5.(?:3|29{5}\d+)
496-5.35:-1:/-5.(?:3|29{5}\d+)
497-0.0065:-1:0.0
498-0.0065:-2:/-0\.01|-1e-02
499-0.0065:-3:/-0\.007|-7e-03
500-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
501-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
5020.05:0:0
5030.5:0:1
5040.51:0:1
5050.41:0:0
506$round_mode = "even"
507+6.23:-1:/6.2(?:0{5}\d+)?
508-6.23:-1:/-6.2(?:0{5}\d+)?
509+6.27:-1:/6.(?:3|29{5}\d+)
510-6.27:-1:/-6.(?:3|29{5}\d+)
511+6.25:-1:/6.(?:2(?:0{5}\d+)?|29{5}\d+)
512-6.25:-1:/-6.(?:2(?:0{5}\d+)?|29{5}\d+)
513+6.35:-1:/6.(?:4|39{5}\d+|29{8}\d+)
514-6.35:-1:/-6.(?:4|39{5}\d+|29{8}\d+)
515-0.0065:-1:0.0
516-0.0065:-2:/-0\.01|-1e-02
517-0.0065:-3:/-0\.006|-7e-03
518-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
519-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
5200.05:0:0
5210.5:0:0
5220.51:0:1
5230.41:0:0
5240.01234567:-3:0.012
5250.01234567:-4:0.0123
5260.01234567:-5:0.01235
5270.01234567:-6:0.012346
5280.01234567:-7:0.0123457
5290.01234567:-8:0.01234567
5300.01234567:-9:0.012345670
5310.01234567:-12:0.012345670000
532&fcmp
533fcmpNaN:fcmpNaN:
534fcmpNaN:+0:
535+0:fcmpNaN:
536+0:+0:0
537-1:+0:-1
538+0:-1:1
539+1:+0:1
540+0:+1:-1
541-1:+1:-1
542+1:-1:1
543-1:-1:0
544+1:+1:0
545-1.1:0:-1
546+0:-1.1:1
547+1.1:+0:1
548+0:+1.1:-1
549+123:+123:0
550+123:+12:1
551+12:+123:-1
552-123:-123:0
553-123:-12:-1
554-12:-123:1
555+123:+124:-1
556+124:+123:1
557-123:-124:1
558-124:-123:-1
5590:0.01:-1
5600:0.0001:-1
5610:-0.0001:1
5620:-0.1:1
5630.1:0:1
5640.00001:0:1
565-0.0001:0:-1
566-0.1:0:-1
5670:0.0001234:-1
5680:-0.0001234:1
5690.0001234:0:1
570-0.0001234:0:-1
5710.0001:0.0005:-1
5720.0005:0.0001:1
5730.005:0.0001:1
5740.001:0.0005:1
5750.000001:0.0005:-1
5760.00000123:0.0005:-1
5770.00512:0.0001:1
5780.005:0.000112:1
5790.00123:0.0005:1
5801.5:2:-1
5812:1.5:1
5821.54321:234:-1
583234:1.54321:1
584# infinity
585-inf:5432112345:-1
586+inf:5432112345:1
587-inf:-5432112345:-1
588+inf:-5432112345:1
589-inf:54321.12345:-1
590+inf:54321.12345:1
591-inf:-54321.12345:-1
592+inf:-54321.12345:1
593+inf:+inf:0
594-inf:-inf:0
595+inf:-inf:1
596-inf:+inf:-1
597# return undef
598+inf:NaN:
599NaN:inf:
600-inf:NaN:
601NaN:-inf:
602&facmp
603fcmpNaN:fcmpNaN:
604fcmpNaN:+0:
605+0:fcmpNaN:
606+0:+0:0
607-1:+0:1
608+0:-1:-1
609+1:+0:1
610+0:+1:-1
611-1:+1:0
612+1:-1:0
613-1:-1:0
614+1:+1:0
615-1.1:0:1
616+0:-1.1:-1
617+1.1:+0:1
618+0:+1.1:-1
619+123:+123:0
620+123:+12:1
621+12:+123:-1
622-123:-123:0
623-123:-12:1
624-12:-123:-1
625+123:+124:-1
626+124:+123:1
627-123:-124:-1
628-124:-123:1
6290:0.01:-1
6300:0.0001:-1
6310:-0.0001:-1
6320:-0.1:-1
6330.1:0:1
6340.00001:0:1
635-0.0001:0:1
636-0.1:0:1
6370:0.0001234:-1
6380:-0.0001234:-1
6390.0001234:0:1
640-0.0001234:0:1
6410.0001:0.0005:-1
6420.0005:0.0001:1
6430.005:0.0001:1
6440.001:0.0005:1
6450.000001:0.0005:-1
6460.00000123:0.0005:-1
6470.00512:0.0001:1
6480.005:0.000112:1
6490.00123:0.0005:1
6501.5:2:-1
6512:1.5:1
6521.54321:234:-1
653234:1.54321:1
654# infinity
655-inf:5432112345:1
656+inf:5432112345:1
657-inf:-5432112345:1
658+inf:-5432112345:1
659-inf:54321.12345:1
660+inf:54321.12345:1
661-inf:-54321.12345:1
662+inf:-54321.12345:1
663+inf:+inf:0
664-inf:-inf:0
665+inf:-inf:0
666-inf:+inf:0
48b581a2 6675:inf:-1
668-1:inf:-1
6695:-inf:-1
670-1:-inf:-1
ee15d750 671# return undef
672+inf:facmpNaN:
673facmpNaN:inf:
674-inf:facmpNaN:
675facmpNaN:-inf:
676&fdec
677fdecNaN:NaN
678+inf:inf
679-inf:-inf
680+0:-1
681+1:0
682-1:-2
6831.23:0.23
684-1.23:-2.23
e745a66c 685100:99
686101:100
687-100:-101
688-99:-100
689-98:-99
69099:98
ee15d750 691&finc
692fincNaN:NaN
693+inf:inf
694-inf:-inf
695+0:1
696+1:2
697-1:0
6981.23:2.23
699-1.23:-0.23
e745a66c 700100:101
701-100:-99
702-99:-98
703-101:-100
70499:100
ee15d750 705&fadd
706abc:abc:NaN
707abc:+0:NaN
708+0:abc:NaN
709+inf:-inf:0
710-inf:+inf:0
711+inf:+inf:inf
712-inf:-inf:-inf
713baddNaN:+inf:NaN
714baddNaN:+inf:NaN
715+inf:baddNaN:NaN
716-inf:baddNaN:NaN
717+0:+0:0
718+1:+0:1
719+0:+1:1
720+1:+1:2
721-1:+0:-1
722+0:-1:-1
723-1:-1:-2
724-1:+1:0
725+1:-1:0
726+9:+1:10
727+99:+1:100
728+999:+1:1000
729+9999:+1:10000
730+99999:+1:100000
731+999999:+1:1000000
732+9999999:+1:10000000
733+99999999:+1:100000000
734+999999999:+1:1000000000
735+9999999999:+1:10000000000
736+99999999999:+1:100000000000
737+10:-1:9
738+100:-1:99
739+1000:-1:999
740+10000:-1:9999
741+100000:-1:99999
742+1000000:-1:999999
743+10000000:-1:9999999
744+100000000:-1:99999999
745+1000000000:-1:999999999
746+10000000000:-1:9999999999
747+123456789:+987654321:1111111110
748-123456789:+987654321:864197532
749-123456789:-987654321:-1111111110
750+123456789:-987654321:-864197532
7510.001234:0.0001234:0.0013574
752&fsub
753abc:abc:NaN
754abc:+0:NaN
755+0:abc:NaN
756+inf:-inf:inf
757-inf:+inf:-inf
758+inf:+inf:0
759-inf:-inf:0
760baddNaN:+inf:NaN
761baddNaN:+inf:NaN
762+inf:baddNaN:NaN
763-inf:baddNaN:NaN
764+0:+0:0
765+1:+0:1
766+0:+1:-1
767+1:+1:0
768-1:+0:-1
769+0:-1:1
770-1:-1:0
771-1:+1:-2
772+1:-1:2
773+9:+1:8
774+99:+1:98
775+999:+1:998
776+9999:+1:9998
777+99999:+1:99998
778+999999:+1:999998
779+9999999:+1:9999998
780+99999999:+1:99999998
781+999999999:+1:999999998
782+9999999999:+1:9999999998
783+99999999999:+1:99999999998
784+10:-1:11
785+100:-1:101
786+1000:-1:1001
787+10000:-1:10001
788+100000:-1:100001
789+1000000:-1:1000001
790+10000000:-1:10000001
791+100000000:-1:100000001
792+1000000000:-1:1000000001
793+10000000000:-1:10000000001
794+123456789:+987654321:-864197532
795-123456789:+987654321:-1111111110
796-123456789:-987654321:864197532
797+123456789:-987654321:1111111110
798&fmul
799abc:abc:NaN
800abc:+0:NaN
801+0:abc:NaN
802+inf:NaNmul:NaN
803+inf:NaNmul:NaN
804NaNmul:+inf:NaN
805NaNmul:-inf:NaN
806+inf:+inf:inf
807+inf:-inf:-inf
808+inf:-inf:-inf
809+inf:+inf:inf
810+inf:123.34:inf
811+inf:-123.34:-inf
812-inf:123.34:-inf
813-inf:-123.34:inf
814123.34:+inf:inf
815-123.34:+inf:-inf
816123.34:-inf:-inf
817-123.34:-inf:inf
818+0:+0:0
819+0:+1:0
820+1:+0:0
821+0:-1:0
822-1:+0:0
823+123456789123456789:+0:0
824+0:+123456789123456789:0
825-1:-1:1
826-1:+1:-1
827+1:-1:-1
828+1:+1:1
829+2:+3:6
830-2:+3:-6
831+2:-3:-6
832-2:-3:6
833+111:+111:12321
834+10101:+10101:102030201
835+1001001:+1001001:1002003002001
836+100010001:+100010001:10002000300020001
837+10000100001:+10000100001:100002000030000200001
838+11111111111:+9:99999999999
839+22222222222:+9:199999999998
840+33333333333:+9:299999999997
841+44444444444:+9:399999999996
842+55555555555:+9:499999999995
843+66666666666:+9:599999999994
844+77777777777:+9:699999999993
845+88888888888:+9:799999999992
846+99999999999:+9:899999999991
8476:120:720
84810:10000:100000
849&fdiv
850$div_scale = 40; $round_mode = 'even'
851abc:abc:NaN
852abc:+1:abc:NaN
853+1:abc:NaN
854-1:abc:NaN
8550:abc:NaN
856+0:+0:NaN
857+0:+1:0
858+1:+0:inf
859+3214:+0:inf
860+0:-1:0
861-1:+0:-inf
862-3214:+0:-inf
863+1:+1:1
864-1:-1:1
865+1:-1:-1
866-1:+1:-1
867+1:+2:0.5
868+2:+1:2
869123:+inf:0
870123:-inf:0
871+10:+5:2
872+100:+4:25
873+1000:+8:125
874+10000:+16:625
875+10000:-16:-625
876+999999999999:+9:111111111111
877+999999999999:+99:10101010101
878+999999999999:+999:1001001001
879+999999999999:+9999:100010001
880+999999999999999:+99999:10000100001
881+1000000000:+9:111111111.1111111111111111111111111111111
882+2000000000:+9:222222222.2222222222222222222222222222222
883+3000000000:+9:333333333.3333333333333333333333333333333
884+4000000000:+9:444444444.4444444444444444444444444444444
885+5000000000:+9:555555555.5555555555555555555555555555556
886+6000000000:+9:666666666.6666666666666666666666666666667
887+7000000000:+9:777777777.7777777777777777777777777777778
888+8000000000:+9:888888888.8888888888888888888888888888889
889+9000000000:+9:1000000000
890+35500000:+113:314159.2920353982300884955752212389380531
891+71000000:+226:314159.2920353982300884955752212389380531
892+106500000:+339:314159.2920353982300884955752212389380531
893+1000000000:+3:333333333.3333333333333333333333333333333
8942:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447
394e6ffb 895123456:1:123456
ee15d750 896$div_scale = 20
897+1000000000:+9:111111111.11111111111
898+2000000000:+9:222222222.22222222222
899+3000000000:+9:333333333.33333333333
900+4000000000:+9:444444444.44444444444
901+5000000000:+9:555555555.55555555556
902+6000000000:+9:666666666.66666666667
903+7000000000:+9:777777777.77777777778
904+8000000000:+9:888888888.88888888889
905+9000000000:+9:1000000000
9061:10:0.1
9071:100:0.01
9081:1000:0.001
9091:10000:0.0001
9101:504:0.001984126984126984127
9112:1.987654321:1.0062111801179738436
394e6ffb 912123456789.123456789123456789123456789:1:123456789.12345678912
ee15d750 913# the next two cases are the "old" behaviour, but are now (>v0.01) different
914#+35500000:+113:314159.292035398230088
915#+71000000:+226:314159.292035398230088
916+35500000:+113:314159.29203539823009
917+71000000:+226:314159.29203539823009
918+106500000:+339:314159.29203539823009
919+1000000000:+3:333333333.33333333333
920$div_scale = 1
921# round to accuracy 1 after bdiv
922+124:+3:40
394e6ffb 923123456789.1234:1:100000000
ee15d750 924# reset scale for further tests
925$div_scale = 40
926&fmod
927+0:0:NaN
928+0:1:0
929+3:1:0
930#+5:2:1
931#+9:4:1
932#+9:5:4
933#+9000:56:40
934#+56:9000:56
935&fsqrt
936+0:0
937-1:NaN
938-2:NaN
939-16:NaN
940-123.45:NaN
941nanfsqrt:NaN
942+inf:inf
943-inf:NaN
394e6ffb 9441:1
9452:1.41421356237309504880168872420969807857
9464:2
9479:3
94816:4
949100:10
950123.456:11.11107555549866648462149404118219234119
95115241.38393:123.4559999756998444766131352122991626468
9521.44:1.2
953# sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4
9541.44E10:120000
9552e10:141421.356237309504880168872420969807857
027dc388 956&is_nan
957123:0
958abc:1
959NaN:1
960-123:0
961&is_inf
962+inf::1
963-inf::1
964abc::0
9651::0
966NaN::0
967-1::0
968+inf:-:0
969+inf:+:1
970-inf:-:1
971-inf:+:0
972# it must be exactly /^[+-]inf$/
973+infinity::0
974-infinity::0
ee15d750 975&is_odd
976abc:0
9770:0
978-1:1
979-3:1
9801:1
9813:1
9821000001:1
9831000002:0
984+inf:0
985-inf:0
986123.45:0
987-123.45:0
9882:0
989&is_even
990abc:0
9910:1
992-1:0
993-3:0
9941:0
9953:0
9961000001:0
9971000002:1
9982:1
999+inf:0
1000-inf:0
1001123.456:0
1002-123.456:0
1003&is_positive
10040:1
10051:1
1006-1:0
1007-123:0
1008NaN:0
1009-inf:0
1010+inf:1
1011&is_negative
10120:0
10131:0
1014-1:1
1015-123:1
1016NaN:0
1017-inf:1
1018+inf:0
1019&parts
10200:0 1
10211:1 0
1022123:123 0
1023-123:-123 0
1024-1200:-12 2
1025NaNparts:NaN NaN
1026+inf:inf inf
1027-inf:-inf inf
1028&exponent
10290:1
10301:0
1031123:0
1032-123:0
1033-1200:2
1034+inf:inf
1035-inf:inf
1036NaNexponent:NaN
1037&mantissa
10380:0
10391:1
1040123:123
1041-123:-123
1042-1200:-12
1043+inf:inf
1044-inf:-inf
1045NaNmantissa:NaN
1046&length
1047123:3
1048-123:3
10490:1
10501:1
105112345678901234567890:20
1052&is_zero
1053NaNzero:0
1054+inf:0
1055-inf:0
10560:1
1057-1:0
10581:0
1059&is_one
1060NaNone:0
1061+inf:0
1062-inf:0
10630:0
10642:0
10651:1
1066-1:0
1067-2:0
027dc388 1068&ffloor
ee15d750 10690:0
1070abc:NaN
1071+inf:inf
1072-inf:-inf
10731:1
1074-51:-51
1075-51.2:-52
107612.2:12
027dc388 1077&fceil
ee15d750 10780:0
1079abc:NaN
1080+inf:inf
1081-inf:-inf
10821:1
1083-51:-51
1084-51.2:-51
108512.2:13