summaryrefslogtreecommitdiff
path: root/dist/Math-BigInt
diff options
context:
space:
mode:
authorpjacklam <pjacklam@online.no>2014-04-15 23:03:18 +0200
committerTony Cook <tony@develop-help.com>2014-05-29 10:27:07 +1000
commit32f4893f37f4f25db406e53fc808a8e75a4f1163 (patch)
treef577a479276252a4194f1571814713a99df8767f /dist/Math-BigInt
parente16b8d1b7d43a6b2453fba2b50c8d1a33b412517 (diff)
downloadperl-32f4893f37f4f25db406e53fc808a8e75a4f1163.tar.gz
Fix RT #62052: Math::BigFloat -> bdiv() in list context
In list context, Math::BigFloat -> bdiv() returns the quotient and remainder. By convention, this means that the quotient and remainder, q and r, after dividing x by y, satisfies x = q*y + r. The current behaviour is to return x/y and r, which do not satisfy this relation, and - more importantly - is not what people expect. dist/Math-BigInt/lib/Math/BigFloat.pm: Patched to fix this bug. t/bigfltpm.inc and t/upgrade.inc: Fixed test cases to match the new behaviour.
Diffstat (limited to 'dist/Math-BigInt')
-rw-r--r--dist/Math-BigInt/lib/Math/BigFloat.pm1
-rw-r--r--dist/Math-BigInt/t/bigfltpm.inc4
-rw-r--r--dist/Math-BigInt/t/upgrade.inc14
3 files changed, 10 insertions, 9 deletions
diff --git a/dist/Math-BigInt/lib/Math/BigFloat.pm b/dist/Math-BigInt/lib/Math/BigFloat.pm
index 33879c9c58..8614bba65a 100644
--- a/dist/Math-BigInt/lib/Math/BigFloat.pm
+++ b/dist/Math-BigInt/lib/Math/BigFloat.pm
@@ -1899,6 +1899,7 @@ sub bdiv
{
if ($y_not_one)
{
+ $x -> bint();
$rem->bmod($y,@params); # copy already done
}
if ($fallback)
diff --git a/dist/Math-BigInt/t/bigfltpm.inc b/dist/Math-BigInt/t/bigfltpm.inc
index 0911627236..1528e48c64 100644
--- a/dist/Math-BigInt/t/bigfltpm.inc
+++ b/dist/Math-BigInt/t/bigfltpm.inc
@@ -1406,8 +1406,8 @@ NaNmul:-inf:NaN
&fdiv-list
0:0:NaN,NaN
0:1:0,0
-9:4:2.25,1
-9:5:1.8,4
+9:4:2,1
+9:5:1,4
# bug in v1.74 with bdiv in list context, when $y is 1 or -1
2.1:-1:-2.1,0
2.1:1:2.1,0
diff --git a/dist/Math-BigInt/t/upgrade.inc b/dist/Math-BigInt/t/upgrade.inc
index 318deb6397..5516fa735c 100644
--- a/dist/Math-BigInt/t/upgrade.inc
+++ b/dist/Math-BigInt/t/upgrade.inc
@@ -834,15 +834,15 @@ NaNmul:-inf:NaN
-4095:-4095:1,0
4095:-4095:-1,0
-4095:4095:-1,0
-123:2:61.5,1
-9:5:1.8,4
-9:4:2.25,1
+123:2:61,1
+9:5:1,4
+9:4:2,1
# inf handling and general remainder
-5:8:0.625,5
+5:8:0,5
0:8:0,0
-11:2:5.5,1
-11:-2:-5.5,-1
--11:2:-5.5,1
+11:2:5,1
+11:-2:-5,-1
+-11:2:-5,1
# see table in documentation in MBI
0:inf:0,0
0:-inf:0,0