Patch: java.math.BigInteger (take 2)

Jerry Quinn jlquinn@optonline.net
Sun Apr 6 15:26:00 GMT 2003


probablePrime is new since 1.4.  This version adds a comment to that effect.

This is the other java.math function that appears to be missing in the
comparison against jdk 1.4.

2003-04-06  Jerry Quinn  <jlquinn@optonline.net>

	* java/math/BigInteger.java (BigInteger::probablePrime): New.

*** BigInteger.java.~1.18.34.4.~	Tue Feb 18 13:15:26 2003
--- BigInteger.java	Sun Apr  6 11:26:37 2003
***************
*** 223,228 ****
--- 223,244 ----
        }
    }
  
+   /** Return a BigInteger that is bitLength bits long with a
+    *  probability < 2^-100 of being composite.
+    *
+    *  @param bitLength length in bits of resulting number
+    *  @param rnd random number generator to use
+    *  @throws ArithmeticException if bitLength < 2
+    *  @since 1.4
+    */
+   public static BigInteger probablePrime(int bitLength, Random rnd)
+   {
+     if (bitLength < 2)
+       throw new ArithmeticException();
+ 
+     return new BigInteger(bitLength, 100, rnd);
+   }
+ 
    /** Return a (possibly-shared) BigInteger with a given long value. */
    public static BigInteger valueOf(long val)
    {



More information about the Java-patches mailing list