This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Math::BigInt from 1.999701 to 1.999704
[perl5.git] / cpan / Math-BigInt / t / bigfltpm.inc
CommitLineData
ee15d750 1#include this file into another test for subclass testing...
b3abae2a 2
3167abe5 3is ($class->config()->{lib},$CL);
b3abae2a 4
56d9de68
T
5use strict;
6
b68b7ab1
T
7my $z;
8
ee15d750
JH
9while (<DATA>)
10 {
f7f86b73 11 $_ =~ s/[\n\r]//g; # remove newlines
ee15d750
JH
12 $_ =~ s/#.*$//; # remove comments
13 $_ =~ s/\s+$//; # trailing spaces
14 next if /^$/; # skip empty lines & comments
15 if (s/^&//)
16 {
17 $f = $_;
18 }
19 elsif (/^\$/)
20 {
21 $setup = $_; $setup =~ s/\$/\$${class}::/g; # round_mode, div_scale
22 #print "\$setup== $setup\n";
23 }
24 else
25 {
26 if (m|^(.*?):(/.+)$|)
27 {
28 $ans = $2;
29 @args = split(/:/,$1,99);
30 }
31 else
32 {
33 @args = split(/:/,$_,99); $ans = pop(@args);
34 }
9b924220 35 $try = "\$x = $class->new(\"$args[0]\");";
ee15d750
JH
36 if ($f eq "fnorm")
37 {
38 $try .= "\$x;";
39 } elsif ($f eq "finf") {
40 $try .= "\$x->finf('$args[1]');";
027dc388
JH
41 } elsif ($f eq "is_inf") {
42 $try .= "\$x->is_inf('$args[1]');";
ee15d750
JH
43 } elsif ($f eq "fone") {
44 $try .= "\$x->bone('$args[1]');";
45 } elsif ($f eq "fstr") {
46 $try .= "\$x->accuracy($args[1]); \$x->precision($args[2]);";
47 $try .= '$x->fstr();';
ee15d750 48 } elsif ($f eq "parts") {
48b581a2 49 # ->bstr() to see if an object is returned
ee15d750
JH
50 $try .= '($a,$b) = $x->parts(); $a = $a->bstr(); $b = $b->bstr();';
51 $try .= '"$a $b";';
ee15d750 52 } elsif ($f eq "exponent") {
48b581a2 53 # ->bstr() to see if an object is returned
ee15d750
JH
54 $try .= '$x->exponent()->bstr();';
55 } elsif ($f eq "mantissa") {
48b581a2 56 # ->bstr() to see if an object is returned
ee15d750 57 $try .= '$x->mantissa()->bstr();';
56d9de68
T
58 } elsif ($f =~ /^(numify|length|as_number|as_hex|as_bin)$/) {
59 $try .= "\$x->$f();";
b3abae2a 60 # some unary ops (test the fxxx form, since that is done by AUTOLOAD)
6358232b 61 } elsif ($f =~ /^f(nan|sstr|neg|floor|ceil|int|abs)$/) {
394e6ffb 62 $try .= "\$x->f$1();";
06ce15ad
SH
63 # overloaded functions
64 } elsif ($f =~ /^(log|exp|sin|cos|atan2|int|neg|abs|sqrt)$/) {
65 $try .= "\$x = $f(\$x);";
027dc388 66 # some is_xxx test function
b3abae2a 67 } elsif ($f =~ /^is_(zero|one|negative|positive|odd|even|nan|int)$/) {
027dc388 68 $try .= "\$x->$f();";
fdb4b05f
T
69 } elsif ($f eq "bpi") {
70 $try .= '$class->bpi($x);';
ee15d750
JH
71 } elsif ($f eq "finc") {
72 $try .= '++$x;';
73 } elsif ($f eq "fdec") {
74 $try .= '--$x;';
75 }elsif ($f eq "fround") {
76 $try .= "$setup; \$x->fround($args[1]);";
77 } elsif ($f eq "ffround") {
78 $try .= "$setup; \$x->ffround($args[1]);";
79 } elsif ($f eq "fsqrt") {
80 $try .= "$setup; \$x->fsqrt();";
b3abae2a
JH
81 } elsif ($f eq "ffac") {
82 $try .= "$setup; \$x->ffac();";
990fb837 83 } elsif ($f eq "flog") {
90d1b129 84 if (defined $args[1] && $args[1] ne '')
990fb837
RGS
85 {
86 $try .= "\$y = $class->new($args[1]);";
87 $try .= "$setup; \$x->flog(\$y);";
88 }
89 else
90 {
91 $try .= "$setup; \$x->flog();";
92 }
ee15d750
JH
93 }
94 else
95 {
990fb837 96 $try .= "\$y = $class->new(\"$args[1]\");";
b68b7ab1
T
97
98 if ($f eq "bgcd")
99 {
100 if (defined $args[2])
101 {
102 $try .= " \$z = $class->new(\"$args[2]\"); ";
103 }
104 $try .= "$class\::bgcd(\$x, \$y";
105 $try .= ", \$z" if (defined $args[2]);
106 $try .= " );";
107 }
108 elsif ($f eq "blcm")
109 {
110 if (defined $args[2])
111 {
112 $try .= " \$z = $class->new(\"$args[2]\"); ";
113 }
114 $try .= "$class\::blcm(\$x, \$y";
115 $try .= ", \$z" if (defined $args[2]);
116 $try .= " );";
117 } elsif ($f eq "fcmp") {
a0ac753d 118 $try .= '$x->fcmp($y);';
ee15d750
JH
119 } elsif ($f eq "facmp") {
120 $try .= '$x->facmp($y);';
121 } elsif ($f eq "fpow") {
122 $try .= '$x ** $y;';
50109ad0
RGS
123 } elsif ($f eq "bnok") {
124 $try .= '$x->bnok($y);';
60a1aa19
T
125 } elsif ($f eq "bcos") {
126 $try .= '$x->bcos($y);';
127 } elsif ($f eq "bsin") {
128 $try .= '$x->bsin($y);';
129 } elsif ($f eq "batan") {
130 $try .= '$x->batan($y);';
990fb837
RGS
131 } elsif ($f eq "froot") {
132 $try .= "$setup; \$x->froot(\$y);";
ee15d750
JH
133 } elsif ($f eq "fadd") {
134 $try .= '$x + $y;';
135 } elsif ($f eq "fsub") {
136 $try .= '$x - $y;';
137 } elsif ($f eq "fmul") {
138 $try .= '$x * $y;';
139 } elsif ($f eq "fdiv") {
140 $try .= "$setup; \$x / \$y;";
b3abae2a
JH
141 } elsif ($f eq "fdiv-list") {
142 $try .= "$setup; join(',',\$x->fdiv(\$y));";
394e6ffb
JH
143 } elsif ($f eq "frsft") {
144 $try .= '$x >> $y;';
145 } elsif ($f eq "flsft") {
146 $try .= '$x << $y;';
ee15d750
JH
147 } elsif ($f eq "fmod") {
148 $try .= '$x % $y;';
80365507
T
149 } else {
150 # Functions with three arguments
151 $try .= "\$z = $class->new(\"$args[2]\");";
152
153 if( $f eq "bmodpow") {
60a1aa19 154 $try .= '$x->bmodpow($y,$z);';
80365507 155 } elsif ($f eq "bmuladd"){
60a1aa19 156 $try .= '$x->bmuladd($y,$z);';
20e2035c
T
157 } elsif ($f eq "batan2"){
158 $try .= '$x->batan2($y,$z);';
80365507
T
159 } else { warn "Unknown op '$f'"; }
160 }
ee15d750 161 }
e745a66c 162 # print "# Trying: '$try'\n";
ee15d750 163 $ans1 = eval $try;
b68b7ab1 164 print "# Error: $@\n" if $@;
ee15d750
JH
165 if ($ans =~ m|^/(.*)$|)
166 {
167 my $pat = $1;
168 if ($ans1 =~ /$pat/)
169 {
3167abe5 170 is (1,1);
ee15d750
JH
171 }
172 else
173 {
3167abe5 174 print "# '$try' expected: /$pat/ got: '$ans1'\n" if !is (1,0);
ee15d750
JH
175 }
176 }
177 else
178 {
179 if ($ans eq "")
180 {
3167abe5 181 is ($ans1, undef);
ee15d750
JH
182 }
183 else
184 {
3167abe5 185 print "# Tried: '$try'\n" if !is ($ans1, $ans);
ee15d750
JH
186 if (ref($ans1) eq "$class")
187 {
027dc388
JH
188 # float numbers are normalized (for now), so mantissa shouldn't have
189 # trailing zeros
ee15d750
JH
190 #print $ans1->_trailing_zeros(),"\n";
191 print "# Has trailing zeros after '$try'\n"
3167abe5 192 if !is ($CL->_zeros( $ans1->{_m}), 0);
ee15d750
JH
193 }
194 }
195 } # end pattern or string
196 }
197 } # end while
198
394e6ffb
JH
199# check whether $class->new( Math::BigInt->new()) destroys it
200# ($y == 12 in this case)
ee15d750 201$x = Math::BigInt->new(1200); $y = $class->new($x);
3167abe5 202is ($y,1200); is ($x,1200);
ee15d750
JH
203
204###############################################################################
f9a08e12
JH
205# Really huge, big, ultra-mega-biggy-monster exponents
206# Technically, the exponents should not be limited (they are BigInts), but
207# practically there are a few places were they are limited to a Perl scalar.
208# This is sometimes for speed, sometimes because otherwise the number wouldn't
209# fit into your memory (just think of 1e123456789012345678901234567890 + 1!)
210# anyway. We don't test everything here, but let's make sure it just basically
211# works.
212
213my $monster = '1e1234567890123456789012345678901234567890';
214
9b924220 215# new and exponent
3167abe5 216is ($class->new($monster)->bsstr(),
56d9de68 217 '1e+1234567890123456789012345678901234567890');
3167abe5 218is ($class->new($monster)->exponent(),
9b924220 219 '1234567890123456789012345678901234567890');
f9a08e12 220# cmp
3167abe5 221is ($class->new($monster) > 0,1);
f9a08e12
JH
222
223# sub/mul
3167abe5
NC
224is ($class->new($monster)->bsub( $monster),0);
225is ($class->new($monster)->bmul(2)->bsstr(),
f9a08e12
JH
226 '2e+1234567890123456789012345678901234567890');
227
9b924220
RGS
228# mantissa
229$monster = '1234567890123456789012345678901234567890e2';
3167abe5 230is ($class->new($monster)->mantissa(),
9b924220
RGS
231 '123456789012345678901234567890123456789');
232
f9a08e12 233###############################################################################
b3abae2a 234# zero,inf,one,nan
ee15d750 235
3167abe5
NC
236$x = $class->new(2); $x->fzero(); is ($x->{_a}, undef); is ($x->{_p}, undef);
237$x = $class->new(2); $x->finf(); is ($x->{_a}, undef); is ($x->{_p}, undef);
238$x = $class->new(2); $x->fone(); is ($x->{_a}, undef); is ($x->{_p}, undef);
239$x = $class->new(2); $x->fnan(); is ($x->{_a}, undef); is ($x->{_p}, undef);
56b9c951
JH
240
241###############################################################################
242# bone/binf etc as plain calls (Lite failed them)
243
3167abe5
NC
244is ($class->fzero(),0);
245is ($class->fone(),1);
246is ($class->fone('+'),1);
247is ($class->fone('-'),-1);
248is ($class->fnan(),'NaN');
249is ($class->finf(),'inf');
250is ($class->finf('+'),'inf');
251is ($class->finf('-'),'-inf');
252is ($class->finf('-inf'),'-inf');
61f5c3f5 253
56d9de68
T
254$class->accuracy(undef); $class->precision(undef); # reset
255
256###############################################################################
257# bug in bsstr()/numify() showed up in after-rounding in bdiv()
258
259$x = $class->new('0.008'); $y = $class->new(2);
260$x->bdiv(3,$y);
3167abe5 261is ($x,'0.0027');
56d9de68 262
61f5c3f5 263###############################################################################
fc399313
PJA
264# Verify that numify() returns a normalized value, and underflows and
265# overflows when given "extreme" values.
266
267like($class->new("12345e67")->numify(), qr/^1\.2345e\+?0*71$/);
268like($class->new("1e-9999")->numify(), qr/^\+?0$/); # underflow
269unlike($class->new("1e9999")->numify(), qr/^1(\.0*)?e\+?9+$/); # overflow
270
271###############################################################################
61f5c3f5
T
272# fsqrt() with set global A/P or A/P enabled on $x, also a test whether fsqrt()
273# correctly modifies $x
274
61f5c3f5 275
3167abe5 276$x = $class->new(12); $class->precision(-2); $x->fsqrt(); is ($x,'3.46');
61f5c3f5
T
277
278$class->precision(undef);
3167abe5 279$x = $class->new(12); $class->precision(0); $x->fsqrt(); is ($x,'3');
61f5c3f5 280
3167abe5 281$class->precision(-3); $x = $class->new(12); $x->fsqrt(); is ($x,'3.464');
61f5c3f5 282
56d9de68
T
283{
284 no strict 'refs';
285 # A and P set => NaN
286 ${${class}.'::accuracy'} = 4; $x = $class->new(12);
3167abe5 287 $x->fsqrt(3); is ($x,'NaN');
56d9de68 288 # supplied arg overrides set global
3167abe5 289 $class->precision(undef); $x = $class->new(12); $x->fsqrt(3); is ($x,'3.46');
56d9de68
T
290 $class->accuracy(undef); $class->precision(undef); # reset for further tests
291}
292
293#############################################################################
13a12e00
JH
294# can we call objectify (broken until v1.52)
295
56d9de68
T
296{
297 no strict;
298 $try =
299 '@args' . " = $class" . "::objectify(2,$class,4,5);".'join(" ",@args);';
300 $ans = eval $try;
3167abe5 301 is ($ans,"$class 4 5");
56d9de68 302}
f9a08e12 303
990fb837
RGS
304#############################################################################
305# is_one('-') (broken until v1.64)
306
3167abe5
NC
307is ($class->new(-1)->is_one(),0);
308is ($class->new(-1)->is_one('-'),1);
990fb837 309
27e7b8bb
T
310#############################################################################
311# bug 1/0.5 leaving 2e-0 instead of 2e0
312
3167abe5 313is ($class->new(1)->fdiv('0.5')->bsstr(),'2e+0');
27e7b8bb 314
03874afe 315###############################################################################
0ac635f7 316# [perl #30609] bug with $x -= $x not being 0, but 2*$x
03874afe 317
3167abe5
NC
318$x = $class->new(3); $x -= $x; is ($x, 0);
319$x = $class->new(-3); $x -= $x; is ($x, 0);
320$x = $class->new(3); $x += $x; is ($x, 6);
321$x = $class->new(-3); $x += $x; is ($x, -6);
03874afe 322
3167abe5
NC
323$x = $class->new('NaN'); $x -= $x; is ($x->is_nan(), 1);
324$x = $class->new('inf'); $x -= $x; is ($x->is_nan(), 1);
325$x = $class->new('-inf'); $x -= $x; is ($x->is_nan(), 1);
03874afe 326
3167abe5
NC
327$x = $class->new('NaN'); $x += $x; is ($x->is_nan(), 1);
328$x = $class->new('inf'); $x += $x; is ($x->is_inf(), 1);
329$x = $class->new('-inf'); $x += $x; is ($x->is_inf('-'), 1);
03874afe 330
3167abe5
NC
331$x = $class->new('3.14'); $x -= $x; is ($x, 0);
332$x = $class->new('-3.14'); $x -= $x; is ($x, 0);
333$x = $class->new('3.14'); $x += $x; is ($x, '6.28');
334$x = $class->new('-3.14'); $x += $x; is ($x, '-6.28');
03874afe 335
3167abe5
NC
336$x = $class->new('3.14'); $x *= $x; is ($x, '9.8596');
337$x = $class->new('-3.14'); $x *= $x; is ($x, '9.8596');
338$x = $class->new('3.14'); $x /= $x; is ($x, '1');
339$x = $class->new('-3.14'); $x /= $x; is ($x, '1');
340$x = $class->new('3.14'); $x %= $x; is ($x, '0');
341$x = $class->new('-3.14'); $x %= $x; is ($x, '0');
03874afe 342
ae161977
RGS
343###############################################################################
344# the following two were reported by "kenny" via hotmail.com:
345
346#perl -MMath::BigFloat -wle 'print Math::BigFloat->new(0)->bpow(".1")'
347#Use of uninitialized value in numeric le (<=) at BigFloat.pm line 1851.
348
349$x = $class->new(0); $y = $class->new('0.1');
3167abe5 350is ($x ** $y, 0, 'no warnings and zero result');
ae161977
RGS
351
352#perl -MMath::BigFloat -lwe 'print Math::BigFloat->new(".222222222222222222222222222222222222222222")->bceil()'
353#Use of uninitialized value in numeric le (<=) at BigFloat.pm line 1851.
354
355$x = $class->new(".222222222222222222222222222222222222222222");
3167abe5 356is ($x->bceil(), 1, 'no warnings and one as result');
ae161977 357
2d2b2744
T
358###############################################################################
359# test **=, <<=, >>=
360
361# ((2^148)-1)/17
362$x = $class->new(2); $x **= 148; $x++; $x->bdiv(17, 60)->bfloor(); $x->accuracy(undef);
3167abe5
NC
363is ($x,"20988936657440586486151264256610222593863921");
364is ($x->length(),length "20988936657440586486151264256610222593863921");
2d2b2744
T
365
366$x = $class->new('2');
367my $y = $class->new('18');
3167abe5
NC
368is ($x <<= $y, 2 << 18);
369is ($x, 2 << 18);
370is ($x >>= $y, 2);
371is ($x, 2);
2d2b2744
T
372
373$x = $class->new('2');
374$y = $class->new('18.2');
375$x <<= $y; # 2 * (2 ** 18.2);
376
3167abe5
NC
377is ($x->copy()->bfround(-9), '602248.763144685');
378is ($x >>= $y, 2); # 2 * (2 ** 18.2) / (2 ** 18.2) => 2
379is ($x, 2);
2d2b2744 380
394e6ffb 3811; # all done
ee15d750 382
ee15d750 383__DATA__
b68b7ab1
T
384&bgcd
385inf:12:NaN
386-inf:12:NaN
38712:inf:NaN
38812:-inf:NaN
389inf:inf:NaN
390inf:-inf:NaN
391-inf:-inf:NaN
392abc:abc:NaN
393abc:+0:NaN
394+0:abc:NaN
395+0:+0:0
396+0:+1:1
397+1:+0:1
398+1:+1:1
399+2:+3:1
400+3:+2:1
401-3:+2:1
402-3:-2:1
403-144:-60:12
404144:-60:12
405144:60:12
406100:625:25
4074096:81:1
4081034:804:2
40927:90:56:1
41027:90:54:9
411&blcm
412abc:abc:NaN
413abc:+0:NaN
414+0:abc:NaN
415+0:+0:NaN
416+1:+0:0
417+0:+1:0
418+27:+90:270
419+1034:+804:415668
b3abae2a 420$div_scale = 40;
60a1aa19
T
421&bcos
4221.2:10:0.3623577545
4232.4:12:-0.737393715541
4240:10:1
4250:20:1
4261:10:0.5403023059
4271:12:0.540302305868
428&bsin
4291:10:0.8414709848
4300:10:0
4310:20:0
4322.1:12:0.863209366649
4331.2:13:0.9320390859672
4340.2:13:0.1986693307951
4353.2:12:-0.0583741434276
20e2035c 436&batan
30afc38d
T
437NaN:10:NaN
438inf:14:1.5707963267949
439-inf:14:-1.5707963267949
20e2035c 4400.2:13:0.1973955598499
30afc38d
T
4410.2:14:0.19739555984988
4420:10:0
4431:14:0.78539816339744
444-1:14:-0.78539816339744
445# test an argument X > 1
4462:14:1.1071487177941
20e2035c 447&batan2
30afc38d
T
448NaN:1:10:NaN
449NaN:NaN:10:NaN
4501:NaN:10:NaN
451inf:1:14:1.5707963267949
452-inf:1:14:-1.5707963267949
0dceeee6
RGS
4530:-inf:14:3.1415926535898
454-1:-inf:14:-3.1415926535898
4551:-inf:14:3.1415926535898
4560:inf:14:0
457inf:-inf:14:2.3561944901923
458-inf:-inf:14:-2.3561944901923
459inf:+inf:14:0.7853981633974
460-inf:+inf:14:-0.7853981633974
20e2035c
T
4611:5:13:0.1973955598499
4621:5:14:0.19739555984988
30afc38d
T
4630:0:10:0
4640:1:14:0
4650:2:14:0
4661:0:14:1.5707963267949
4675:0:14:1.5707963267949
468-1:0:11:-1.5707963268
469-2:0:77:-1.5707963267948966192313216916397514420985846996875529104874722961539082031431
4702:0:77:1.5707963267948966192313216916397514420985846996875529104874722961539082031431
471-1:5:14:-0.19739555984988
4721:5:14:0.19739555984988
473-1:8:14:-0.12435499454676
4741:8:14:0.12435499454676
475-1:1:14:-0.78539816339744
476# test an argument X > 1 and one X < 1
4771:2:24:0.463647609000806116214256
4782:1:14:1.1071487177941
479-2:1:14:-1.1071487177941
fdb4b05f 480&bpi
20e2035c 481150:3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940813
fdb4b05f
T
48277:3.1415926535897932384626433832795028841971693993751058209749445923078164062862
483+0:3.141592653589793238462643383279502884197
20e2035c 48411:3.1415926536
50109ad0
RGS
485&bnok
486+inf:10:inf
487NaN:NaN:NaN
488NaN:1:NaN
4891:NaN:NaN
4901:1:1
491# k > n
4921:2:0
4932:3:0
494# k < 0
4951:-2:0
496# 7 over 3 = 35
4977:3:35
d5735945 4987:6:7
50109ad0 499100:90:17310309456440
d5735945
PF
500100:95:75287520
5012:0:1
5027:0:1
5032:1:2
b3abae2a 504&flog
06ce15ad 5050::-inf
990fb837
RGS
506-1::NaN
507-2::NaN
508# base > 0, base != 1
5092:-1:NaN
06ce15ad 5102:0:0
990fb837 5112:1:NaN
06ce15ad 512# log(1)
990fb837 5131::0
06ce15ad 5141:1:NaN
990fb837 5151:2:0
90d1b129
T
5162::0.6931471805599453094172321214581765680755
5172.718281828::0.9999999998311266953289851340574956564911
518$div_scale = 20;
5192.718281828::0.99999999983112669533
520$div_scale = 15;
521123::4.81218435537242
52210::2.30258509299405
5231000::6.90775527898214
524100::4.60517018598809
5252::0.693147180559945
5263.1415::1.14470039286086
52712345::9.42100640177928
5280.001::-6.90775527898214
529# bug until v1.71:
53010:10:1
531100:100:1
b3abae2a
JH
532# reset for further tests
533$div_scale = 40;
990fb837 5341::0
394e6ffb 535&frsft
b3abae2a 536NaNfrsft:2:NaN
394e6ffb
JH
5370:2:0
5381:1:0.5
5392:1:1
5404:1:2
541123:1:61.5
54232:3:4
543&flsft
b3abae2a 544NaNflsft:0:NaN
394e6ffb
JH
5452:1:4
5464:3:32
5475:3:40
5481:2:4
5490:5:0
ee15d750
JH
550&fnorm
5511:1
552-0:0
553fnormNaN:NaN
554+inf:inf
555-inf:-inf
556123:123
557-123.4567:-123.4567
027dc388
JH
558# invalid inputs
5591__2:NaN
5601E1__2:NaN
56111__2E2:NaN
027dc388 562.2E-3.:NaN
2d2b2744
T
5631e3e4:NaN
564# strange, but valid
027dc388 565.2E2:20
2d2b2744
T
5661.E3:1000
567# some inputs that result in zero
5680e0:0
569+0e0:0
570+0e+0:0
571-0e+0:0
5720e-0:0
573-0e-0:0
574+0e-0:0
575000:0
57600e2:0
57700e02:0
578000e002:0
579000e1230:0
58000e-3:0
58100e+3:0
58200e-03:0
58300e+03:0
584-000:0
585-00e2:0
586-00e02:0
587-000e002:0
588-000e1230:0
589-00e-3:0
590-00e+3:0
591-00e-03:0
592-00e+03:0
ee15d750
JH
593&as_number
5940:0
5951:1
5961.2:1
5972.345:2
598-2:-2
599-123.456:-123
600-200:-200
3d6017f5
PJA
601-inf:-inf
602inf:inf
603NaN:NaN
26c6d654 60471243225429896467497217836789578596379:71243225429896467497217836789578596379
56d9de68
T
605# test for bug in brsft() not handling cases that return 0
6060.000641:0
6070.0006412:0
6080.00064123:0
6090.000641234:0
6100.0006412345:0
6110.00064123456:0
6120.000641234567:0
6130.0006412345678:0
6140.00064123456789:0
6150.1:0
6160.01:0
6170.001:0
6180.0001:0
6190.00001:0
6200.000001:0
6210.0000001:0
6220.00000001:0
6230.000000001:0
6240.0000000001:0
6250.00000000001:0
990fb837
RGS
6260.12345:0
6270.123456:0
6280.1234567:0
6290.12345678:0
6300.123456789:0
ee15d750
JH
631&finf
6321:+:inf
6332:-:-inf
6343:abc:inf
56d9de68
T
635&as_hex
636+inf:inf
637-inf:-inf
638hexNaN:NaN
6390:0x0
6405:0x5
641-5:-0x5
642&as_bin
643+inf:inf
644-inf:-inf
645hexNaN:NaN
6460:0b0
6475:0b101
648-5:-0b101
ee15d750 649&numify
56d9de68 650# uses bsstr() so 5 => 5e+0 to be compatible w/ Perls output
fc399313
PJA
6510:0
652+1:1
6531234:1234
654-5:-5
655100:100
656-100:-100
ee15d750
JH
657&fnan
658abc:NaN
6592:NaN
660-2:NaN
6610:NaN
662&fone
6632:+:1
664-2:-:-1
665-2:+:1
6662:-:-1
6670::1
668-2::1
669abc::1
6702:abc:1
671&fsstr
672+inf:inf
673-inf:-inf
674abcfsstr:NaN
56d9de68 675-abcfsstr:NaN
ee15d750 6761234.567:1234567e-3
56d9de68
T
677123:123e+0
678-5:-5e+0
679-100:-1e+2
ee15d750
JH
680&fstr
681+inf:::inf
682-inf:::-inf
683abcfstr:::NaN
6841234.567:9::1234.56700
6851234.567::-6:1234.567000
68612345:5::12345
6870.001234:6::0.00123400
6880.001234::-8:0.00123400
6890:4::0
6900::-4:0.0000
691&fnorm
692inf:inf
693+inf:inf
694-inf:-inf
695+infinity:NaN
696+-inf:NaN
697abc:NaN
698 1 a:NaN
6991bcd2:NaN
70011111b:NaN
701+1z:NaN
702-1z:NaN
aef458a0
JH
7030e999:0
7040e-999:0
705-0e999:0
706-0e-999:0
ee15d750
JH
7070:0
708+0:0
709+00:0
710+0_0_0:0
711000000_0000000_00000:0
712-0:0
713-0000:0
714+1:1
715+01:1
716+001:1
717+00000100000:100000
718123456789:123456789
719-1:-1
720-01:-1
721-001:-1
722-123456789:-123456789
723-00000100000:-100000
724123.456a:NaN
725123.456:123.456
7260.01:0.01
727.002:0.002
728+.2:0.2
729-0.0003:-0.0003
730-.0000000004:-0.0000000004
731123456E2:12345600
732123456E-2:1234.56
733-123456E2:-12345600
734-123456E-2:-1234.56
7351e1:10
7362e-11:0.00000000002
c4a6f826 737# exercise _split
ee15d750
JH
738 .02e-1:0.002
739 000001:1
740 -00001:-1
741 -1:-1
742 000.01:0.01
743 -000.0023:-0.0023
744 1.1e1:11
745-3e111:-3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
746-4e-1111:-0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004
747&fpow
9b924220
RGS
748NaN:1:NaN
7491:NaN:NaN
750NaN:-1:NaN
751-1:NaN:NaN
752NaN:-21:NaN
753-21:NaN:NaN
754NaN:21:NaN
75521:NaN:NaN
7560:0:1
7570:1:0
7580:9:0
7590:-2:inf
ee15d750
JH
7602:2:4
7611:2:1
7621:3:1
763-1:2:1
764-1:3:-1
765123.456:2:15241.383936
7662:-2:0.25
7672:-3:0.125
768128:-2:0.00006103515625
769abc:123.456:NaN
770123.456:abc:NaN
771+inf:123.45:inf
772-inf:123.45:-inf
773+inf:-123.45:inf
774-inf:-123.45:-inf
9b924220
RGS
775-2:2:4
776-2:3:-8
777-2:4:16
778-2:5:-32
779-3:2:9
780-3:3:-27
781-3:4:81
782-3:5:-243
79c55733
JH
783# 2 ** 0.5 == sqrt(2)
784# 1.41..7 and not 1.4170 since fallback (bsqrt(9) is '3', not 3.0...0)
7852:0.5:1.41421356237309504880168872420969807857
56b9c951 786#2:0.2:1.148698354997035006798626946777927589444
07d34614 787#6:1.5:14.6969384566990685891837044482353483518
56b9c951
JH
788$div_scale = 20;
789#62.5:12.5:26447206647554886213592.3959144
790$div_scale = 40;
ee15d750
JH
791&fneg
792fnegNaN:NaN
793+inf:-inf
794-inf:inf
795+0:0
796+1:-1
797-1:1
798+123456789:-123456789
799-123456789:123456789
800+123.456789:-123.456789
801-123456.789:123456.789
802&fabs
803fabsNaN:NaN
804+inf:inf
805-inf:inf
806+0:0
807+1:1
808-1:1
809+123456789:123456789
810-123456789:123456789
811+123.456789:123.456789
812-123456.789:123456.789
813&fround
814$round_mode = "trunc"
815+inf:5:inf
816-inf:5:-inf
8170:5:0
818NaNfround:5:NaN
819+10123456789:5:10123000000
820-10123456789:5:-10123000000
821+10123456789.123:5:10123000000
822-10123456789.123:5:-10123000000
823+10123456789:9:10123456700
824-10123456789:9:-10123456700
825+101234500:6:101234000
826-101234500:6:-101234000
827$round_mode = "zero"
828+20123456789:5:20123000000
829-20123456789:5:-20123000000
830+20123456789.123:5:20123000000
831-20123456789.123:5:-20123000000
832+20123456789:9:20123456800
833-20123456789:9:-20123456800
834+201234500:6:201234000
835-201234500:6:-201234000
836$round_mode = "+inf"
837+30123456789:5:30123000000
838-30123456789:5:-30123000000
839+30123456789.123:5:30123000000
840-30123456789.123:5:-30123000000
841+30123456789:9:30123456800
842-30123456789:9:-30123456800
843+301234500:6:301235000
844-301234500:6:-301234000
845$round_mode = "-inf"
846+40123456789:5:40123000000
847-40123456789:5:-40123000000
848+40123456789.123:5:40123000000
849-40123456789.123:5:-40123000000
850+40123456789:9:40123456800
851-40123456789:9:-40123456800
852+401234500:6:401234000
853-401234500:6:-401235000
854$round_mode = "odd"
855+50123456789:5:50123000000
856-50123456789:5:-50123000000
857+50123456789.123:5:50123000000
858-50123456789.123:5:-50123000000
859+50123456789:9:50123456800
860-50123456789:9:-50123456800
861+501234500:6:501235000
862-501234500:6:-501235000
863$round_mode = "even"
864+60123456789:5:60123000000
865-60123456789:5:-60123000000
866+60123456789:9:60123456800
867-60123456789:9:-60123456800
868+601234500:6:601234000
869-601234500:6:-601234000
870+60123456789.0123:5:60123000000
871-60123456789.0123:5:-60123000000
7b29e1e6
T
872$round_mode = "common"
873+60123456789:5:60123000000
874-60123456789:5:-60123000000
875+60123456789:6:60123500000
876-60123456789:6:-60123500000
877+60123456789:9:60123456800
878-60123456789:9:-60123456800
879+601234500:6:601235000
880-601234500:6:-601235000
881+601234400:6:601234000
882-601234400:6:-601234000
883+601234600:6:601235000
884-601234600:6:-601235000
885+601234300:6:601234000
886+60123456789.0123:5:60123000000
887-60123456789.0123:5:-60123000000
ee15d750
JH
888&ffround
889$round_mode = "trunc"
890+inf:5:inf
891-inf:5:-inf
8920:5:0
893NaNffround:5:NaN
894+1.23:-1:1.2
895+1.234:-1:1.2
896+1.2345:-1:1.2
897+1.23:-2:1.23
898+1.234:-2:1.23
899+1.2345:-2:1.23
900+1.23:-3:1.230
901+1.234:-3:1.234
902+1.2345:-3:1.234
903-1.23:-1:-1.2
904+1.27:-1:1.2
905-1.27:-1:-1.2
906+1.25:-1:1.2
907-1.25:-1:-1.2
908+1.35:-1:1.3
909-1.35:-1:-1.3
910-0.0061234567890:-1:0.0
911-0.0061:-1:0.0
912-0.00612:-1:0.0
913-0.00612:-2:0.00
914-0.006:-1:0.0
915-0.006:-2:0.00
916-0.0006:-2:0.00
917-0.0006:-3:0.000
918-0.0065:-3:/-0\.006|-6e-03
919-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
920-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
9210.05:0:0
9220.5:0:0
9230.51:0:0
9240.41:0:0
925$round_mode = "zero"
926+2.23:-1:/2.2(?:0{5}\d+)?
927-2.23:-1:/-2.2(?:0{5}\d+)?
928+2.27:-1:/2.(?:3|29{5}\d+)
929-2.27:-1:/-2.(?:3|29{5}\d+)
930+2.25:-1:/2.2(?:0{5}\d+)?
931-2.25:-1:/-2.2(?:0{5}\d+)?
932+2.35:-1:/2.(?:3|29{5}\d+)
933-2.35:-1:/-2.(?:3|29{5}\d+)
934-0.0065:-1:0.0
935-0.0065:-2:/-0\.01|-1e-02
936-0.0065:-3:/-0\.006|-6e-03
937-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
938-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
9390.05:0:0
9400.5:0:0
9410.51:0:1
9420.41:0:0
943$round_mode = "+inf"
944+3.23:-1:/3.2(?:0{5}\d+)?
945-3.23:-1:/-3.2(?:0{5}\d+)?
946+3.27:-1:/3.(?:3|29{5}\d+)
947-3.27:-1:/-3.(?:3|29{5}\d+)
948+3.25:-1:/3.(?:3|29{5}\d+)
949-3.25:-1:/-3.2(?:0{5}\d+)?
950+3.35:-1:/3.(?:4|39{5}\d+)
951-3.35:-1:/-3.(?:3|29{5}\d+)
952-0.0065:-1:0.0
953-0.0065:-2:/-0\.01|-1e-02
954-0.0065:-3:/-0\.006|-6e-03
955-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
956-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
9570.05:0:0
9580.5:0:1
9590.51:0:1
9600.41:0:0
961$round_mode = "-inf"
962+4.23:-1:/4.2(?:0{5}\d+)?
963-4.23:-1:/-4.2(?:0{5}\d+)?
964+4.27:-1:/4.(?:3|29{5}\d+)
965-4.27:-1:/-4.(?:3|29{5}\d+)
966+4.25:-1:/4.2(?:0{5}\d+)?
967-4.25:-1:/-4.(?:3|29{5}\d+)
968+4.35:-1:/4.(?:3|29{5}\d+)
969-4.35:-1:/-4.(?:4|39{5}\d+)
970-0.0065:-1:0.0
971-0.0065:-2:/-0\.01|-1e-02
972-0.0065:-3:/-0\.007|-7e-03
973-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
974-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
9750.05:0:0
9760.5:0:0
9770.51:0:1
9780.41:0:0
979$round_mode = "odd"
980+5.23:-1:/5.2(?:0{5}\d+)?
981-5.23:-1:/-5.2(?:0{5}\d+)?
982+5.27:-1:/5.(?:3|29{5}\d+)
983-5.27:-1:/-5.(?:3|29{5}\d+)
984+5.25:-1:/5.(?:3|29{5}\d+)
985-5.25:-1:/-5.(?:3|29{5}\d+)
986+5.35:-1:/5.(?:3|29{5}\d+)
987-5.35:-1:/-5.(?:3|29{5}\d+)
988-0.0065:-1:0.0
989-0.0065:-2:/-0\.01|-1e-02
990-0.0065:-3:/-0\.007|-7e-03
991-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
992-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
9930.05:0:0
9940.5:0:1
9950.51:0:1
9960.41:0:0
997$round_mode = "even"
998+6.23:-1:/6.2(?:0{5}\d+)?
999-6.23:-1:/-6.2(?:0{5}\d+)?
1000+6.27:-1:/6.(?:3|29{5}\d+)
1001-6.27:-1:/-6.(?:3|29{5}\d+)
1002+6.25:-1:/6.(?:2(?:0{5}\d+)?|29{5}\d+)
1003-6.25:-1:/-6.(?:2(?:0{5}\d+)?|29{5}\d+)
1004+6.35:-1:/6.(?:4|39{5}\d+|29{8}\d+)
1005-6.35:-1:/-6.(?:4|39{5}\d+|29{8}\d+)
1006-0.0065:-1:0.0
1007-0.0065:-2:/-0\.01|-1e-02
1008-0.0065:-3:/-0\.006|-7e-03
1009-0.0065:-4:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
1010-0.0065:-5:/-0\.006(?:5|49{5}\d+)|-6\.5e-03
10110.05:0:0
10120.5:0:0
10130.51:0:1
10140.41:0:0
10150.01234567:-3:0.012
10160.01234567:-4:0.0123
10170.01234567:-5:0.01235
10180.01234567:-6:0.012346
10190.01234567:-7:0.0123457
10200.01234567:-8:0.01234567
10210.01234567:-9:0.012345670
10220.01234567:-12:0.012345670000
1023&fcmp
1024fcmpNaN:fcmpNaN:
1025fcmpNaN:+0:
1026+0:fcmpNaN:
1027+0:+0:0
1028-1:+0:-1
1029+0:-1:1
1030+1:+0:1
1031+0:+1:-1
1032-1:+1:-1
1033+1:-1:1
1034-1:-1:0
1035+1:+1:0
1036-1.1:0:-1
1037+0:-1.1:1
1038+1.1:+0:1
1039+0:+1.1:-1
1040+123:+123:0
1041+123:+12:1
1042+12:+123:-1
1043-123:-123:0
1044-123:-12:-1
1045-12:-123:1
1046+123:+124:-1
1047+124:+123:1
1048-123:-124:1
1049-124:-123:-1
10500:0.01:-1
10510:0.0001:-1
10520:-0.0001:1
10530:-0.1:1
10540.1:0:1
10550.00001:0:1
1056-0.0001:0:-1
1057-0.1:0:-1
10580:0.0001234:-1
10590:-0.0001234:1
10600.0001234:0:1
1061-0.0001234:0:-1
10620.0001:0.0005:-1
10630.0005:0.0001:1
10640.005:0.0001:1
10650.001:0.0005:1
10660.000001:0.0005:-1
10670.00000123:0.0005:-1
10680.00512:0.0001:1
10690.005:0.000112:1
10700.00123:0.0005:1
10711.5:2:-1
10722:1.5:1
10731.54321:234:-1
1074234:1.54321:1
aa45dafa
PJA
10751e1234567890987654321:1e1234567890987654320:1
10761e-1234567890987654321:1e-1234567890987654320:-1
ee15d750
JH
1077# infinity
1078-inf:5432112345:-1
1079+inf:5432112345:1
1080-inf:-5432112345:-1
1081+inf:-5432112345:1
1082-inf:54321.12345:-1
1083+inf:54321.12345:1
1084-inf:-54321.12345:-1
1085+inf:-54321.12345:1
1086+inf:+inf:0
1087-inf:-inf:0
1088+inf:-inf:1
1089-inf:+inf:-1
1090# return undef
1091+inf:NaN:
1092NaN:inf:
1093-inf:NaN:
1094NaN:-inf:
1095&facmp
1096fcmpNaN:fcmpNaN:
1097fcmpNaN:+0:
1098+0:fcmpNaN:
1099+0:+0:0
1100-1:+0:1
1101+0:-1:-1
1102+1:+0:1
1103+0:+1:-1
1104-1:+1:0
1105+1:-1:0
1106-1:-1:0
1107+1:+1:0
1108-1.1:0:1
1109+0:-1.1:-1
1110+1.1:+0:1
1111+0:+1.1:-1
1112+123:+123:0
1113+123:+12:1
1114+12:+123:-1
1115-123:-123:0
1116-123:-12:1
1117-12:-123:-1
1118+123:+124:-1
1119+124:+123:1
1120-123:-124:-1
1121-124:-123:1
11220:0.01:-1
11230:0.0001:-1
11240:-0.0001:-1
11250:-0.1:-1
11260.1:0:1
11270.00001:0:1
1128-0.0001:0:1
1129-0.1:0:1
11300:0.0001234:-1
11310:-0.0001234:-1
11320.0001234:0:1
1133-0.0001234:0:1
11340.0001:0.0005:-1
11350.0005:0.0001:1
11360.005:0.0001:1
11370.001:0.0005:1
11380.000001:0.0005:-1
11390.00000123:0.0005:-1
11400.00512:0.0001:1
11410.005:0.000112:1
11420.00123:0.0005:1
11431.5:2:-1
11442:1.5:1
11451.54321:234:-1
1146234:1.54321:1
1147# infinity
1148-inf:5432112345:1
1149+inf:5432112345:1
1150-inf:-5432112345:1
1151+inf:-5432112345:1
1152-inf:54321.12345:1
1153+inf:54321.12345:1
1154-inf:-54321.12345:1
1155+inf:-54321.12345:1
1156+inf:+inf:0
1157-inf:-inf:0
1158+inf:-inf:0
1159-inf:+inf:0
48b581a2
JH
11605:inf:-1
1161-1:inf:-1
11625:-inf:-1
1163-1:-inf:-1
ee15d750
JH
1164# return undef
1165+inf:facmpNaN:
1166facmpNaN:inf:
1167-inf:facmpNaN:
1168facmpNaN:-inf:
1169&fdec
1170fdecNaN:NaN
1171+inf:inf
1172-inf:-inf
1173+0:-1
1174+1:0
1175-1:-2
11761.23:0.23
1177-1.23:-2.23
e745a66c
JH
1178100:99
1179101:100
1180-100:-101
1181-99:-100
1182-98:-99
118399:98
ee15d750
JH
1184&finc
1185fincNaN:NaN
1186+inf:inf
1187-inf:-inf
1188+0:1
1189+1:2
1190-1:0
11911.23:2.23
1192-1.23:-0.23
e745a66c
JH
1193100:101
1194-100:-99
1195-99:-98
1196-101:-100
119799:100
ee15d750
JH
1198&fadd
1199abc:abc:NaN
1200abc:+0:NaN
1201+0:abc:NaN
13a12e00
JH
1202+inf:-inf:NaN
1203-inf:+inf:NaN
ee15d750
JH
1204+inf:+inf:inf
1205-inf:-inf:-inf
1206baddNaN:+inf:NaN
1207baddNaN:+inf:NaN
1208+inf:baddNaN:NaN
1209-inf:baddNaN:NaN
1210+0:+0:0
1211+1:+0:1
1212+0:+1:1
1213+1:+1:2
1214-1:+0:-1
1215+0:-1:-1
1216-1:-1:-2
1217-1:+1:0
1218+1:-1:0
1219+9:+1:10
1220+99:+1:100
1221+999:+1:1000
1222+9999:+1:10000
1223+99999:+1:100000
1224+999999:+1:1000000
1225+9999999:+1:10000000
1226+99999999:+1:100000000
1227+999999999:+1:1000000000
1228+9999999999:+1:10000000000
1229+99999999999:+1:100000000000
1230+10:-1:9
1231+100:-1:99
1232+1000:-1:999
1233+10000:-1:9999
1234+100000:-1:99999
1235+1000000:-1:999999
1236+10000000:-1:9999999
1237+100000000:-1:99999999
1238+1000000000:-1:999999999
1239+10000000000:-1:9999999999
1240+123456789:+987654321:1111111110
1241-123456789:+987654321:864197532
1242-123456789:-987654321:-1111111110
1243+123456789:-987654321:-864197532
12440.001234:0.0001234:0.0013574
1245&fsub
1246abc:abc:NaN
1247abc:+0:NaN
1248+0:abc:NaN
1249+inf:-inf:inf
1250-inf:+inf:-inf
13a12e00
JH
1251+inf:+inf:NaN
1252-inf:-inf:NaN
ee15d750
JH
1253baddNaN:+inf:NaN
1254baddNaN:+inf:NaN
1255+inf:baddNaN:NaN
1256-inf:baddNaN:NaN
1257+0:+0:0
1258+1:+0:1
1259+0:+1:-1
1260+1:+1:0
1261-1:+0:-1
1262+0:-1:1
1263-1:-1:0
1264-1:+1:-2
1265+1:-1:2
1266+9:+1:8
1267+99:+1:98
1268+999:+1:998
1269+9999:+1:9998
1270+99999:+1:99998
1271+999999:+1:999998
1272+9999999:+1:9999998
1273+99999999:+1:99999998
1274+999999999:+1:999999998
1275+9999999999:+1:9999999998
1276+99999999999:+1:99999999998
1277+10:-1:11
1278+100:-1:101
1279+1000:-1:1001
1280+10000:-1:10001
1281+100000:-1:100001
1282+1000000:-1:1000001
1283+10000000:-1:10000001
1284+100000000:-1:100000001
1285+1000000000:-1:1000000001
1286+10000000000:-1:10000000001
1287+123456789:+987654321:-864197532
1288-123456789:+987654321:-1111111110
1289-123456789:-987654321:864197532
1290+123456789:-987654321:1111111110
80365507
T
1291&bmuladd
1292abc:abc:0:NaN
1293abc:+0:0:NaN
1294+0:abc:0:NaN
1295+0:0:abc:NaN
1296NaNmul:+inf:0:NaN
1297NaNmul:-inf:0:NaN
1298-inf:NaNmul:0:NaN
1299+inf:NaNmul:0:NaN
1300+inf:+inf:0:inf
1301+inf:-inf:0:-inf
1302-inf:+inf:0:-inf
1303-inf:-inf:0:inf
1304+0:+0:0:0
1305+0:+1:0:0
1306+1:+0:0:0
1307+0:-1:0:0
1308-1:+0:0:0
1309123456789123456789:0:0:0
13100:123456789123456789:0:0
1311-1:-1:0:1
1312-1:-1:0:1
1313-1:+1:0:-1
1314+1:-1:0:-1
1315+1:+1:0:1
1316+2:+3:0:6
1317-2:+3:0:-6
1318+2:-3:0:-6
1319-2:-3:0:6
1320111:111:0:12321
132110101:10101:0:102030201
13221001001:1001001:0:1002003002001
1323100010001:100010001:0:10002000300020001
132410000100001:10000100001:0:100002000030000200001
132511111111111:9:0:99999999999
132622222222222:9:0:199999999998
132733333333333:9:0:299999999997
132844444444444:9:0:399999999996
132955555555555:9:0:499999999995
133066666666666:9:0:599999999994
133177777777777:9:0:699999999993
133288888888888:9:0:799999999992
133399999999999:9:0:899999999991
133411111111111:9:1:100000000000
133522222222222:9:1:199999999999
133633333333333:9:1:299999999998
133744444444444:9:1:399999999997
133855555555555:9:1:499999999996
133966666666666:9:1:599999999995
134077777777777:9:1:699999999994
134188888888888:9:1:799999999993
134299999999999:9:1:899999999992
1343-3:-4:-5:7
13443:-4:-5:-17
1345-3:4:-5:-17
13463:4:-5:7
1347-3:4:5:-7
13483:-4:5:-7
13499999999999999999999:10000000000000000000:1234567890:99999999999999999990000000001234567890
13503.2:5.7:8.9:27.14
1351-3.2:5.197:6.05:-10.5804
1352&bmodpow
13533:4:8:1
13543:4:7:4
13553:4:7:4
135677777:777:123456789:99995084
13573.2:6.2:5.2:2.970579856718063040273642739529400818
ee15d750
JH
1358&fmul
1359abc:abc:NaN
1360abc:+0:NaN
1361+0:abc:NaN
1362+inf:NaNmul:NaN
1363+inf:NaNmul:NaN
1364NaNmul:+inf:NaN
1365NaNmul:-inf:NaN
1366+inf:+inf:inf
1367+inf:-inf:-inf
1368+inf:-inf:-inf
1369+inf:+inf:inf
1370+inf:123.34:inf
1371+inf:-123.34:-inf
1372-inf:123.34:-inf
1373-inf:-123.34:inf
1374123.34:+inf:inf
1375-123.34:+inf:-inf
1376123.34:-inf:-inf
1377-123.34:-inf:inf
1378+0:+0:0
1379+0:+1:0
1380+1:+0:0
1381+0:-1:0
1382-1:+0:0
1383+123456789123456789:+0:0
1384+0:+123456789123456789:0
1385-1:-1:1
1386-1:+1:-1
1387+1:-1:-1
1388+1:+1:1
1389+2:+3:6
1390-2:+3:-6
1391+2:-3:-6
1392-2:-3:6
1393+111:+111:12321
1394+10101:+10101:102030201
1395+1001001:+1001001:1002003002001
1396+100010001:+100010001:10002000300020001
1397+10000100001:+10000100001:100002000030000200001
1398+11111111111:+9:99999999999
1399+22222222222:+9:199999999998
1400+33333333333:+9:299999999997
1401+44444444444:+9:399999999996
1402+55555555555:+9:499999999995
1403+66666666666:+9:599999999994
1404+77777777777:+9:699999999993
1405+88888888888:+9:799999999992
1406+99999999999:+9:899999999991
14076:120:720
140810:10000:100000
b3abae2a 1409&fdiv-list
b4a10d33 14100:0:NaN,0
b3abae2a 14110:1:0,0
32f4893f 14129:4:2,1
14139:5:1,4
233f7bc0
T
1414# bug in v1.74 with bdiv in list context, when $y is 1 or -1
14152.1:-1:-2.1,0
14162.1:1:2.1,0
1417-2.1:-1:2.1,0
1418-2.1:1:-2.1,0
ee15d750
JH
1419&fdiv
1420$div_scale = 40; $round_mode = 'even'
1421abc:abc:NaN
1422abc:+1:abc:NaN
1423+1:abc:NaN
1424-1:abc:NaN
14250:abc:NaN
1426+0:+0:NaN
1427+0:+1:0
1428+1:+0:inf
1429+3214:+0:inf
1430+0:-1:0
1431-1:+0:-inf
1432-3214:+0:-inf
1433+1:+1:1
1434-1:-1:1
1435+1:-1:-1
1436-1:+1:-1
1437+1:+2:0.5
1438+2:+1:2
1439123:+inf:0
1440123:-inf:0
1441+10:+5:2
1442+100:+4:25
1443+1000:+8:125
1444+10000:+16:625
1445+10000:-16:-625
1446+999999999999:+9:111111111111
1447+999999999999:+99:10101010101
1448+999999999999:+999:1001001001
1449+999999999999:+9999:100010001
1450+999999999999999:+99999:10000100001
1451+1000000000:+9:111111111.1111111111111111111111111111111
1452+2000000000:+9:222222222.2222222222222222222222222222222
1453+3000000000:+9:333333333.3333333333333333333333333333333
1454+4000000000:+9:444444444.4444444444444444444444444444444
1455+5000000000:+9:555555555.5555555555555555555555555555556
1456+6000000000:+9:666666666.6666666666666666666666666666667
1457+7000000000:+9:777777777.7777777777777777777777777777778
1458+8000000000:+9:888888888.8888888888888888888888888888889
1459+9000000000:+9:1000000000
1460+35500000:+113:314159.2920353982300884955752212389380531
1461+71000000:+226:314159.2920353982300884955752212389380531
1462+106500000:+339:314159.2920353982300884955752212389380531
1463+1000000000:+3:333333333.3333333333333333333333333333333
14642:25.024996000799840031993601279744051189762:0.07992009269196593320152084692285869265447
394e6ffb 1465123456:1:123456
ee15d750
JH
1466$div_scale = 20
1467+1000000000:+9:111111111.11111111111
1468+2000000000:+9:222222222.22222222222
1469+3000000000:+9:333333333.33333333333
1470+4000000000:+9:444444444.44444444444
1471+5000000000:+9:555555555.55555555556
1472+6000000000:+9:666666666.66666666667
1473+7000000000:+9:777777777.77777777778
1474+8000000000:+9:888888888.88888888889
1475+9000000000:+9:1000000000
14761:10:0.1
14771:100:0.01
14781:1000:0.001
14791:10000:0.0001
14801:504:0.001984126984126984127
14812:1.987654321:1.0062111801179738436
394e6ffb 1482123456789.123456789123456789123456789:1:123456789.12345678912
ee15d750
JH
1483# the next two cases are the "old" behaviour, but are now (>v0.01) different
1484#+35500000:+113:314159.292035398230088
1485#+71000000:+226:314159.292035398230088
1486+35500000:+113:314159.29203539823009
1487+71000000:+226:314159.29203539823009
1488+106500000:+339:314159.29203539823009
1489+1000000000:+3:333333333.33333333333
1490$div_scale = 1
1491# round to accuracy 1 after bdiv
1492+124:+3:40
394e6ffb 1493123456789.1234:1:100000000
ee15d750
JH
1494# reset scale for further tests
1495$div_scale = 40
1496&fmod
61f5c3f5
T
1497+9:4:1
1498+9:5:4
1499+9000:56:40
1500+56:9000:56
1501# inf handling, see table in doc
15020:inf:0
15030:-inf:0
15045:inf:5
b4a10d33
PJA
15055:-inf:-inf
1506-5:inf:inf
61f5c3f5 1507-5:-inf:-5
b4a10d33
PJA
1508inf:5:NaN
1509-inf:5:NaN
1510inf:-5:NaN
1511-inf:-5:NaN
61f5c3f5
T
15125:5:0
1513-5:-5:0
b3abae2a
JH
1514inf:inf:NaN
1515-inf:-inf:NaN
1516-inf:inf:NaN
1517inf:-inf:NaN
61f5c3f5
T
15188:0:8
1519inf:0:inf
61f5c3f5
T
1520-inf:0:-inf
1521-8:0:-8
b4a10d33 15220:0:0
61f5c3f5
T
1523abc:abc:NaN
1524abc:1:abc:NaN
15251:abc:NaN
61f5c3f5
T
15260:1:0
15271:0:1
15280:-1:0
1529-1:0:-1
15301:1:0
1531-1:-1:0
15321:-1:0
1533-1:1:0
15341:2:1
15352:1:0
15361000000000:9:1
15372000000000:9:2
15383000000000:9:3
15394000000000:9:4
15405000000000:9:5
15416000000000:9:6
15427000000000:9:7
15438000000000:9:8
15449000000000:9:0
154535500000:113:33
154671000000:226:66
1547106500000:339:99
15481000000000:3:1
154910:5:0
1550100:4:0
15511000:8:0
155210000:16:0
1553999999999999:9:0
1554999999999999:99:0
1555999999999999:999:0
1556999999999999:9999:0
1557999999999999999:99999:0
1558-9:+5:1
1559+9:-5:-1
1560-9:-5:-4
1561-5:3:1
1562-2:3:1
15634:3:1
15641:3:1
1565-5:-3:-2
1566-2:-3:-2
15674:-3:-2
15681:-3:-2
15694095:4095:0
1570100041000510123:3:0
1571152403346:12345:4321
157287654321:87654321:0
1573# now some floating point tests
1574123:2.5:0.5
15751230:2.5:0
1576123.4:2.5:0.9
1577123e1:25:5
7596a890
RGS
1578-2.1:1:0.9
15792.1:1:0.1
1580-2.1:-1:-0.1
15812.1:-1:-0.9
233f7bc0
T
1582-3:1:0
15833:1:0
1584-3:-1:0
15853:-1:0
b3abae2a
JH
1586&ffac
1587Nanfac:NaN
1588-1:NaN
b282a552 1589+inf:inf
091c87b1 1590-inf:NaN
b3abae2a
JH
15910:1
15921:1
15932:2
15943:6
15954:24
15965:120
15976:720
159810:3628800
159911:39916800
160012:479001600
990fb837
RGS
1601&froot
1602# sqrt()
1603+0:2:0
1604+1:2:1
1605-1:2:NaN
1606# -$x ** (1/2) => -$y, but not in froot()
1607-123.456:2:NaN
1608+inf:2:inf
1609-inf:2:NaN
16102:2:1.41421356237309504880168872420969807857
1611-2:2:NaN
16124:2:2
16139:2:3
161416:2:4
1615100:2:10
1616123.456:2:11.11107555549866648462149404118219234119
161715241.38393:2:123.4559999756998444766131352122991626468
16181.44:2:1.2
161912:2:3.464101615137754587054892683011744733886
16200.49:2:0.7
16210.0049:2:0.07
1622# invalid ones
16231:NaN:NaN
1624-1:NaN:NaN
16250:NaN:NaN
1626-inf:NaN:NaN
1627+inf:NaN:NaN
1628NaN:0:NaN
1629NaN:2:NaN
1630NaN:inf:NaN
1631NaN:inf:NaN
163212:-inf:NaN
163312:inf:NaN
1634+0:0:NaN
1635+1:0:NaN
1636-1:0:NaN
1637-2:0:NaN
1638-123.45:0:NaN
1639+inf:0:NaN
164012:1:12
1641-12:1:NaN
16428:-1:NaN
1643-8:-1:NaN
1644# cubic root
16458:3:2
1646-8:3:NaN
1647# fourths root
164816:4:2
164981:4:3
3a427a11 1650# see t/bigroot() for more tests
ee15d750
JH
1651&fsqrt
1652+0:0
1653-1:NaN
1654-2:NaN
1655-16:NaN
1656-123.45:NaN
1657nanfsqrt:NaN
1658+inf:inf
1659-inf:NaN
394e6ffb
JH
16601:1
16612:1.41421356237309504880168872420969807857
16624:2
16639:3
166416:4
1665100:10
1666123.456:11.11107555549866648462149404118219234119
166715241.38393:123.4559999756998444766131352122991626468
16681.44:1.2
1669# sqrt(1.44) = 1.2, sqrt(e10) = e5 => 12e4
16701.44E10:120000
16712e10:141421.356237309504880168872420969807857
b3abae2a 1672144e20:120000000000
61f5c3f5
T
1673# proved to be an endless loop under 7-9
167412:3.464101615137754587054892683011744733886
990fb837
RGS
16750.49:0.7
16760.0049:0.07
027dc388
JH
1677&is_nan
1678123:0
1679abc:1
1680NaN:1
1681-123:0
1682&is_inf
1683+inf::1
1684-inf::1
1685abc::0
16861::0
1687NaN::0
1688-1::0
1689+inf:-:0
1690+inf:+:1
1691-inf:-:1
1692-inf:+:0
1693# it must be exactly /^[+-]inf$/
1694+infinity::0
1695-infinity::0
ee15d750
JH
1696&is_odd
1697abc:0
16980:0
1699-1:1
1700-3:1
17011:1
17023:1
17031000001:1
17041000002:0
1705+inf:0
1706-inf:0
1707123.45:0
1708-123.45:0
17092:0
b3abae2a
JH
1710&is_int
1711NaNis_int:0
17120:1
17131:1
17142:1
1715-2:1
1716-1:1
1717-inf:0
1718+inf:0
1719123.4567:0
1720-0.1:0
1721-0.002:0
ee15d750
JH
1722&is_even
1723abc:0
17240:1
1725-1:0
1726-3:0
17271:0
17283:0
17291000001:0
17301000002:1
17312:1
1732+inf:0
1733-inf:0
1734123.456:0
1735-123.456:0
b3abae2a
JH
17360.01:0
1737-0.01:0
1738120:1
17391200:1
1740-1200:1
ee15d750 1741&is_positive
b68b7ab1 17420:0
ee15d750
JH
17431:1
1744-1:0
1745-123:0
1746NaN:0
1747-inf:0
1748+inf:1
1749&is_negative
17500:0
17511:0
1752-1:1
1753-123:1
1754NaN:0
1755-inf:1
1756+inf:0
1757&parts
17580:0 1
17591:1 0
1760123:123 0
1761-123:-123 0
1762-1200:-12 2
1763NaNparts:NaN NaN
1764+inf:inf inf
1765-inf:-inf inf
1766&exponent
17670:1
17681:0
1769123:0
1770-123:0
1771-1200:2
1772+inf:inf
1773-inf:inf
1774NaNexponent:NaN
1775&mantissa
17760:0
17771:1
1778123:123
1779-123:-123
1780-1200:-12
1781+inf:inf
1782-inf:-inf
1783NaNmantissa:NaN
1784&length
1785123:3
1786-123:3
17870:1
17881:1
178912345678901234567890:20
1790&is_zero
1791NaNzero:0
1792+inf:0
1793-inf:0
17940:1
1795-1:0
17961:0
1797&is_one
1798NaNone:0
1799+inf:0
1800-inf:0
18010:0
18022:0
18031:1
1804-1:0
1805-2:0
027dc388 1806&ffloor
ee15d750
JH
18070:0
1808abc:NaN
1809+inf:inf
1810-inf:-inf
18111:1
1812-51:-51
1813-51.2:-52
181412.2:12
990fb837
RGS
18150.12345:0
18160.123456:0
18170.1234567:0
18180.12345678:0
18190.123456789:0
027dc388 1820&fceil
ee15d750
JH
18210:0
1822abc:NaN
1823+inf:inf
1824-inf:-inf
18251:1
1826-51:-51
1827-51.2:-51
182812.2:13
669bc510 1829-0.4:0
6358232b
PJA
1830&fint
18310:0
1832NaN:NaN
1833+inf:inf
1834-inf:-inf
18351:1
1836-51:-51
1837-51.2:-51
183812.2:12
669bc510 1839-0.4:0
06ce15ad
SH
1840# overloaded functions
1841&log
1842-1:NaN
18430:-inf
18441:0
18452:0.6931471805599453094172321214581765680755
18463:1.098612288668109691395245236922525704647
1847123456789:18.63140176616801803319393334796320420971
18481234567890987654321:41.657252696908474880343847955484513481
1849-inf:inf
1850inf:inf
1851NaN:NaN
1852&exp
1853&sin
1854&cos
1855&atan2
1856&int
1857&neg
1858&abs
1859&sqrt