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

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

commit 2990405a68c0835270f1cf2c7c7ed0902c7a0f17
Author: Dana Jacobsen <d...@acm.org>
Date:   Fri Jan 18 20:22:30 2013 -0800

    Fix more bignum issues
---
 MANIFEST                  |  1 +
 lib/Math/Prime/Util.pm    |  2 ++
 lib/Math/Prime/Util/PP.pm |  2 ++
 t/70-rt-bignum.t          | 27 +++++++++++++++++++++++++++
 4 files changed, 32 insertions(+)

diff --git a/MANIFEST b/MANIFEST
index 046dd78..cc0cb5e 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -77,6 +77,7 @@ t/30-relations.t
 t/31-threading.t
 t/50-factoring.t
 t/51-primearray.t
+5/70-rt-bignum.t
 t/80-pp.t
 t/81-bignum.t
 t/90-release-perlcritic.t
diff --git a/lib/Math/Prime/Util.pm b/lib/Math/Prime/Util.pm
index fa632fc..18e50b1 100644
--- a/lib/Math/Prime/Util.pm
+++ b/lib/Math/Prime/Util.pm
@@ -222,6 +222,8 @@ sub _validate_positive_integer {
   } elsif (ref($n) ne 'Math::BigInt') {
     croak "Parameter '$n' outside of integer range" if !defined 
$bigint::VERSION;
     $_[0] = Math::BigInt->new("$n"); # Make $n a proper bigint object
+  } else {
+    $_[0]->upgrade(undef) if $_[0]->upgrade();  # Stop BigFloat upgrade
   }
   # One of these will be true:
   #     1) $n <= max and $n is not a bigint
diff --git a/lib/Math/Prime/Util/PP.pm b/lib/Math/Prime/Util/PP.pm
index ade5de9..f2f87fb 100644
--- a/lib/Math/Prime/Util/PP.pm
+++ b/lib/Math/Prime/Util/PP.pm
@@ -74,6 +74,8 @@ sub _validate_positive_integer {
   } elsif (ref($n) ne 'Math::BigInt') {
     croak "Parameter '$n' outside of integer range" if !defined 
$bigint::VERSION;
     $_[0] = Math::BigInt->new("$n"); # Make $n a proper bigint object
+  } else {
+    $_[0]->upgrade(undef) if $_[0]->upgrade();  # Stop BigFloat upgrade
   }
   # One of these will be true:
   #     1) $n <= max and $n is not a bigint
diff --git a/t/70-rt-bignum.t b/t/70-rt-bignum.t
new file mode 100644
index 0000000..f63a321
--- /dev/null
+++ b/t/70-rt-bignum.t
@@ -0,0 +1,27 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+# I found these issues when doing some testing of is_provable_prime.  When
+# bignum is loaded, we get some strange behavior.  There are two fixes for
+# it in the code:
+#  1) make sure every divide and bdiv is coerced back to an integer.
+#  2) turn off upgrade in input validation.
+# The second method in theory is all that is needed.
+
+use Math::Prime::Util qw/:all/;
+use bignum;
+
+use Test::More tests => 1;
+
+my $n = 
100199294509778143137521762187425301691197073534078445671945250753109628678272;
+# 2 2 2 2 2 2 2 3 7 509 277772399 
263650456338779643073784729209358382310353002641378210462709359
+
+my @partial_factor = 
Math::Prime::Util::PP::prho_factor(100199294509778143137521762187425301691197073534078445671945250753109628678272,
 5);
+
+is_deeply( \@partial_factor, 
+           
[2,2,2,2,2,2,2,3,7,37276523255125797298185179385202865212498911284999421752955822452793760669],
+           "PP prho factors correctly with 'use bignum'" );
+
+# The same thing happens in random primes, PP holf factoring,
+# PP is_provable_primes, and possibly elsewhere

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

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to