diff options
| author | Tom Tromey <tromey@redhat.com> | 2003-04-19 19:25:24 +0000 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2003-04-19 19:25:24 +0000 |
| commit | 33fa22900f43e7945c4fee835c24ed1adaa0479f (patch) | |
| tree | e64bd2bef2d93dd13aaf9a8040a4b513048152ee /java/math/BigInteger.java | |
| parent | 9f094a1d9ed277488452bf1088597594b0357951 (diff) | |
| download | classpath-33fa22900f43e7945c4fee835c24ed1adaa0479f.tar.gz | |
2003-04-19 Jerry Quinn <jlquinn@optonline.net>
* java/math/BigInteger.java (probablePrime): New.
* java/math/BigDecimal.java (unscaledValue): New.
Diffstat (limited to 'java/math/BigInteger.java')
| -rw-r--r-- | java/math/BigInteger.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/java/math/BigInteger.java b/java/math/BigInteger.java index 6f919f785..34ec5a4c4 100644 --- a/java/math/BigInteger.java +++ b/java/math/BigInteger.java @@ -223,6 +223,23 @@ public class BigInteger extends Number implements Comparable } } + /** + * 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) { |
