[libmath-prime-util-perl] 52/54: 32-bit with Math::BigInt::GMP causes havoc because of its RT71548

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:52:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.38
in repository libmath-prime-util-perl.

commit ba4ac8a8c71b3a113d0c18c3a34246b1e6c1af56
Author: Dana Jacobsen <dana at acm.org>
Date:   Fri Feb 28 10:59:19 2014 -0800

    32-bit with Math::BigInt::GMP causes havoc because of its RT71548
---
 xt/primecount-approx.t | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/xt/primecount-approx.t b/xt/primecount-approx.t
index 5bd6976..e01d1ef 100644
--- a/xt/primecount-approx.t
+++ b/xt/primecount-approx.t
@@ -4,7 +4,6 @@ use warnings;
 
 use Test::More;
 use Math::Prime::Util qw/prime_count prime_count_lower prime_count_upper prime_count_approx/;
-use Digest::SHA qw/sha256_hex/;
 
 my %pivals = (
                 1000 =>                168,
@@ -130,13 +129,17 @@ my %pivals = (
  18446744073709551615 => 425656284035217743,
 );
 
+use Math::BigInt try=>"GMP,Pari";
 plan tests => 3*scalar(keys %pivals);
 
 foreach my $n (sort {$a <=> $b} keys %pivals) {
   my $pin = $pivals{$n};
-  cmp_ok( prime_count_upper($n), '>=', $pin, "Pi($n) <= upper estimate" );
-  cmp_ok( prime_count_lower($n), '<=', $pin, "Pi($n) >= lower estimate" );
-  my $approx = prime_count_approx($n);
+  $n = Math::BigInt->new($n) if $n > ~0;
+  # stringify to work around Math::BigInt::GMP's stupid bug
+  cmp_ok( ''.prime_count_upper($n), '>=', $pin, "Pi($n) <= upper estimate" );
+  cmp_ok( ''.prime_count_lower($n), '<=', $pin, "Pi($n) >= lower estimate" );
+  # Result may be bigint, so turn into float for percentage comparison
+  my $approx = 0.0 + ''.prime_count_approx($n);
   my $percent_limit = ($n > 1000000000000) ? 0.00005
                     : ($n >   10000000000) ? 0.0002
                     : ($n >     100000000) ? 0.002

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list