New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] Fix RT #62052: Math::BigFloat -> bdiv() in list context #13738
Comments
From @pjacklamFix RT #62052: Math::BigFloat -> bdiv() in list context In list context, Math::BigFloat -> bdiv() returns the quotient and remainder. 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. |
From @pjacklam0001-Fix-RT-62052-Math-BigFloat-bdiv-in-list-context.patchFrom be301d08cac86cfc69ed7e5c535a74e7f55930f5 Mon Sep 17 00:00:00 2001
From: pjacklam <pjacklam@online.no>
Date: Tue, 15 Apr 2014 23:03:18 +0200
Subject: [PATCH] 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.
---
dist/Math-BigInt/lib/Math/BigFloat.pm | 1 +
dist/Math-BigInt/t/bigfltpm.inc | 4 ++--
dist/Math-BigInt/t/upgrade.inc | 14 +++++++-------
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 fb1d206..0486e4f 100644
--- a/dist/Math-BigInt/lib/Math/BigFloat.pm
+++ b/dist/Math-BigInt/lib/Math/BigFloat.pm
@@ -1895,6 +1895,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 0911627..1528e48 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 318deb6..5516fa7 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
--
1.7.9
|
From @tonycozOn Tue Apr 15 14:12:23 2014, pjacklam wrote:
Thanks, I'll apply this after 5.20 is released. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Tue Apr 15 14:12:23 2014, pjacklam wrote:
Thanks, applied as 32f4893. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#121668 (status was 'resolved')
Searchable as RT121668$
The text was updated successfully, but these errors were encountered: