I'm checking this in.

This fixes a possible overflow in isProbablePrime.

Tom

2007-08-28  John X  <[EMAIL PROTECTED]>

        PR classpath/33206:
        * java/math/BigInteger.java (isProbablePrime): Handle case of
        large 'b'.

Index: java/math/BigInteger.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.32
diff -u -r1.32 BigInteger.java
--- java/math/BigInteger.java   21 Dec 2006 13:02:53 -0000      1.32
+++ java/math/BigInteger.java   28 Aug 2007 18:35:39 -0000
@@ -1,5 +1,5 @@
 /* java.math.BigInteger -- Arbitary precision integers
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006  Free Software 
Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007  Free 
Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -1313,7 +1313,7 @@
     int b = pMinus1.getLowestSetBit();
 
     // Set m such that this = 1 + 2^b * m.
-    BigInteger m = pMinus1.divide(valueOf(2L << b - 1));
+    BigInteger m = pMinus1.divide(valueOf(2L).pow(b));
 
     // The HAC (Handbook of Applied Cryptography), Alfred Menezes & al. Note
     // 4.49 (controlling the error probability) gives the number of trials

Reply via email to