-#include this file into another for subclass testing
+# include this file into another for subclass testing
# This file is nearly identical to bigintpm.t, except that certain results
# are _requird_ to be different due to "upgrading" or "promoting" to BigFloat.
# The reverse is not true, any unmarked results can be either BigInt or
-# BigFloat, depending on how good the internal optimization is.
+# BigFloat, depending on how good the internal optimization is (e.g. it
+# is usually desirable to have 2 ** 2 return a BigInt, not a BigFloat).
-# Plaese note that the testcount goes up by two for each extra result marked
+# Results that are required to be BigFloat are marked with C<^> at the end.
+
+# Please note that the testcount goes up by two for each extra result marked
# with ^, since then we test whether it has the proper class and that it left
# the upgrade variable alone.
while (<DATA>)
{
- chop;
+ chomp;
next if /^#/; # skip comments
if (s/^&//)
{
$try .= '$e = $e->bstr(); $e = "NaN" if !defined $e;';
$try .= '"$m,$e";';
} else {
- $try .= "\$y = $class->new('$args[1]');";
+ if ($args[1] !~ /\./)
+ {
+ $try .= "\$y = $class->new(\"$args[1]\");"; # BigInt
+ }
+ else
+ {
+ $try .= "\$y = $ECL->new(\"$args[1]\");"; # BigFloat
+ }
if ($f eq "bcmp")
{
$try .= '$x <=> $y;';
} elsif ($f eq "bround") {
$try .= "$round_mode; \$x->bround(\$y);";
+ } elsif ($f eq "broot") {
+ $try .= "\$x->broot(\$y);";
} elsif ($f eq "bacmp"){
$try .= '$x->bacmp($y);';
} elsif ($f eq "badd"){
} # endwhile data tests
close DATA;
+my $warn = ''; $SIG{__WARN__} = sub { $warn = shift; };
+
+# these should not warn
+$warn = ''; eval "\$z = 3.17 <= \$y"; ok ($z, 1); ok ($warn, '');
+$warn = ''; eval "\$z = \$y >= 3.17"; ok ($z, 1); ok ($warn, '');
+
# all tests done
1;
100:3:1
8:9:8
&/=
-100:3:33
+100:3:33.33333333333333333333333333333333333333
-8:2:-4
&|=
2:1:3
-123456789:987654321:864197532
-123456789:-987654321:-1111111110
+123456789:-987654321:-864197532
-#2:2.5:4.5^
-#-123:-1.5:-124.5^
-#-1.2:1:-0.2^
+2:2.5:4.5^
+-123:-1.5:-124.5^
+-1.2:1:-0.2^
&bsub
abc:abc:NaN
abc:+0:NaN
99999999999999999:100000000000000000:9999999999999999900000000000000000
999999999999999999:1000000000000000000:999999999999999999000000000000000000
9999999999999999999:10000000000000000000:99999999999999999990000000000000000000
+3:3.5:10.5^
+3.5:3:10.5^
&bdiv-list
100:20:5,0
4095:4095:1,0
-4095:-4095:1,0
4095:-4095:-1,0
-4095:4095:-1,0
-123:2:61,1
-9:5:1,4
-9:4:2,1
+123:2:61.5,1
+9:5:1.8,4
+9:4:2.25,1
# inf handling and general remainder
5:8:0.625,5
0:8:0,0
-11:2:5,1
-11:-2:-5,-1
--11:2:-5,1
+11:2:5.5,1
+11:-2:-5.5,-1
+-11:2:-5.5,1
# see table in documentation in MBI
0:inf:0,0
0:-inf:0,0
-8:0:-inf
-inf:0:-inf
0:0:NaN
-11:2:5
--11:-2:5
--11:2:-5
-11:-2:-5
+11:2:5.5^
+-11:-2:5.5^
+-11:2:-5.5^
+11:-2:-5.5^
0:1:0
0:-1:0
1:1:1
-1:1:-1
1:2:0.5^
2:1:2
-1000000000:9:111111111
-2000000000:9:222222222
-3000000000:9:333333333
-4000000000:9:444444444
-5000000000:9:555555555
-6000000000:9:666666666
-7000000000:9:777777777
-8000000000:9:888888888
+1000000000:9:111111111.1111111111111111111111111111111^
+2000000000:9:222222222.2222222222222222222222222222222^
+3000000000:9:333333333.3333333333333333333333333333333^
+4000000000:9:444444444.4444444444444444444444444444444^
+5000000000:9:555555555.5555555555555555555555555555556^
+6000000000:9:666666666.6666666666666666666666666666667^
+7000000000:9:777777777.7777777777777777777777777777778^
+8000000000:9:888888888.8888888888888888888888888888889^
9000000000:9:1000000000
-35500000:113:314159
-71000000:226:314159
-106500000:339:314159
-1000000000:3:333333333
+35500000:113:314159.2920353982300884955752212389380531^
+71000000:226:314159.2920353982300884955752212389380531^
+106500000:339:314159.2920353982300884955752212389380531^
+1000000000:3:333333333.3333333333333333333333333333333^
+10:+5:2
+100:+4:25
+1000:+8:125
999999999999:9999:100010001
999999999999999:99999:10000100001
+1111088889:99999:11111
--5:-3:1
--5:3:-1
-4:3:1
-4:-3:-1
-1:3:0.3333333333333333333333333333333333333333
-1:-3:-0.3333333333333333333333333333333333333333
--2:-3:0.6666666666666666666666666666666666666667
--2:3:-0.6666666666666666666666666666666666666667
-#8:5:1.6^
-#-8:5:-1.6^
-8:5:1
--8:5:-1
-14:-3:-4
--14:3:-4
--14:-3:4
-14:3:4
+-5:-3:1.666666666666666666666666666666666666667^
+-5:3:-1.666666666666666666666666666666666666667^
+4:3:1.333333333333333333333333333333333333333^
+4:-3:-1.333333333333333333333333333333333333333^
+1:3:0.3333333333333333333333333333333333333333^
+1:-3:-0.3333333333333333333333333333333333333333^
+-2:-3:0.6666666666666666666666666666666666666667^
+-2:3:-0.6666666666666666666666666666666666666667^
+8:5:1.6^
+-8:5:-1.6^
+14:-3:-4.666666666666666666666666666666666666667^
+-14:3:-4.666666666666666666666666666666666666667^
+-14:-3:4.666666666666666666666666666666666666667^
+14:3:4.666666666666666666666666666666666666667^
# bug in Calc with '99999' vs $BASE-1
-10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
+#10000000000000000000000000000000000000000000000000000000000000000000000000000000000:10000000375084540248994272022843165711074:999999962491547381984643365663244474111576
12:24:0.5^
&bmod
# inf handling, see table in doc
&bfac
-1:NaN
NaNfac:NaN
-+inf:NaN
++inf:inf
-inf:NaN
0:1
1:1
0:0:1
0:1:0
0:2:0
-0:-1:NaN
-0:-2:NaN
+0:-1:inf
+0:-2:inf
1:0:1
1:1:1
1:2:1
-1:-2:1
-1:-3:-1
-1:-4:1
+-2:2:4
+-2:3:-8
+-2:4:16
+-2:5:-32
+-3:2:9
+-3:3:-27
+-3:4:81
+-3:5:-243
10:2:100
10:3:1000
10:4:10000
10:9:1000000000
10:20:100000000000000000000
123456:2:15241383936
+#2:0.5:1.41^
&length
100:3
10:2
10000000000000000:17
-123:3
215960156869840440586892398248:30
+# broot always upgrades
+&broot
+144:2:12^
+123:2:11.09053650640941716205160010260993291846^
+# bsqrt always upgrades
&bsqrt
145:12.04159457879229548012824103037860805243^
144:12^
-2:NaN
-123:NaN
Nan:NaN
-+inf:NaN
++inf:inf
+-inf:NaN
&bround
$round_mode('trunc')
0:12:0