This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix RT #62052: Math::BigFloat -> bdiv() in list context
authorpjacklam <pjacklam@online.no>
Tue, 15 Apr 2014 21:03:18 +0000 (23:03 +0200)
committerTony Cook <tony@develop-help.com>
Thu, 29 May 2014 00:27:07 +0000 (10:27 +1000)
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
dist/Math-BigInt/t/bigfltpm.inc
dist/Math-BigInt/t/upgrade.inc

index 33879c9..8614bba 100644 (file)
@@ -1899,6 +1899,7 @@ sub bdiv
     {
     if ($y_not_one)
       {
+      $x -> bint();
       $rem->bmod($y,@params);                  # copy already done
       }
     if ($fallback)
index 0911627..1528e48 100644 (file)
@@ -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
index 318deb6..5516fa7 100644 (file)
@@ -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