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

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

commit 4562fd0abd3ad4134ef1fa44a8975ba66f4bb766
Author: Dana Jacobsen <d...@acm.org>
Date:   Tue Mar 5 08:49:54 2013 -0800

    Fix 32-bit issues
---
 lehmer.c | 11 ++++++++++-
 util.h   |  6 +++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/lehmer.c b/lehmer.c
index 7aa57b2..cc666d1 100644
--- a/lehmer.c
+++ b/lehmer.c
@@ -185,7 +185,11 @@ static UV icbrt(UV n)
 {
 #if 0
   /* The integer cube root code is about 30% faster for me */
+#if BITS_PER_WORD == 32
+  if (n >= UVCONST(4291015625)) return UVCONST(1625);
+#else
   if (n >= UVCONST(18446724184312856125)) return UVCONST(2642245);
+#endif
   UV root = (UV) pow(n, 1.0/3.0);
   if (root*root*root > n) {
     root--;
@@ -197,7 +201,12 @@ static UV icbrt(UV n)
 #else
   int s;
   UV y = 0;
-  for (s = (sizeof(UV)*8)-1; s >= 0; s -= 3) {
+  /* Alternately: s = (sizeof(UV)*8)-(sizeof(UV)*8)%3 */
+#if BITS_PER_WORD == 32
+  for (s = 30; s >= 0; s -= 3) {
+#else
+  for (s = 63; s >= 0; s -= 3) {
+#endif
     UV b;
     y += y;
     b = 3*y*(y+1)+1;
diff --git a/util.h b/util.h
index a2d7f7c..15c4c8d 100644
--- a/util.h
+++ b/util.h
@@ -34,11 +34,11 @@ extern double _XS_RiemannR(double x);
 #endif
 
 static UV isqrt(UV n) {
- #if BIT_PER_WORD == 32
+#if BITS_PER_WORD == 32
   if (n >= UVCONST(4294836225)) return UVCONST(65535);
- #else
+#else
   if (n >= UVCONST(18446744065119617025)) return UVCONST(4294967295);
- #endif
+#endif
   UV root = (UV) sqrt((double)n);
   while (root*root > n)  root--;
   while ((root+1)*(root+1) <= n)  root++;

-- 
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