tag 417528 patch
found 417528 5.8.8-12
found 417528 5.10.0-6
thanks

On Mon, Apr 02, 2007 at 07:33:05PM -0400, Alan Curry wrote:
> Package: perl-modules
> Version: 5.8.4-8sarge5
> Severity: normal
> 
> $ perl -le 'print sqrt(sqrt(2)**3)'
> 1.68179283050743
> $ perl -le 'use bignum; print sqrt(sqrt(2)**3)'
> 9.101797207145410796943657706576305980854
> $ perl -le 'use bignum lib => "GMP"; print sqrt(sqrt(2)**3)'
> 1.681792830507429086062250952466429790081

Hi,

this is still present in Perl 5.8.8 and 5.10.0 (although the wrong result
is different on 5.10.0).

I just sent a failing testcase and a patch to the Math-BigInt CPAN bug
tracker at

 http://rt.cpan.org/Public/Bug/Display.html?id=34459

Attached as well, the fix applies (with quite some fuzz) to the version
bundled with Perl 5.8.8 too.

Cheers,
-- 
Niko Tyni   [EMAIL PROTECTED]
diff --git a/lib/Math/BigFloat.pm b/lib/Math/BigFloat.pm
index f2eb0a4..9f986be 100644
--- a/lib/Math/BigFloat.pm
+++ b/lib/Math/BigFloat.pm
@@ -2142,8 +2142,9 @@ sub bsqrt
   # But we need at least $scale digits, so calculate how many are missing
   my $shift = $scale - $digits;
 
-  # That should never happen (we take care of integer guesses above)
-  # $shift = 0 if $shift < 0; 
+  # This happens if the input had enough digits 
+  # (we take care of integer guesses above)
+  $shift = 0 if $shift < 0; 
 
   # Multiply in steps of 100, by shifting left two times the "missing" digits
   my $s2 = $shift * 2;
diff --git a/t/mbimbf.t b/t/mbimbf.t
index fae3c8c..88201e1 100755
--- a/t/mbimbf.t
+++ b/t/mbimbf.t
@@ -32,7 +32,7 @@ BEGIN
   print "# INC = @INC\n";
 
   plan tests => 684 
-    + 23;		# own tests
+    + 26;		# own tests
   }
 
 use Math::BigInt 1.70;
@@ -100,3 +100,9 @@ $x = Math::BigFloat->new(100);
 $x = $x->blog(Math::BigInt->new(10));
 
 ok ($x,2);
+
+for my $i (80,88,100) {
+    $x = Math::BigFloat->new("1." . ("0" x $i) . "1");
+    $x = $x->bsqrt;
+    ok ($x, 1);
+}

Reply via email to