diff options
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/math/BigDecimal.java | 5 | ||||
-rw-r--r-- | libjava/java/math/BigInteger.java | 17 |
3 files changed, 27 insertions, 0 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index d7d7bd3..ee610a8 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-04-19 Jerry Quinn <jlquinn@optonline.net> + + * java/math/BigInteger.java (probablePrime): New. + * java/math/BigDecimal.java (unscaledValue): New. + 2003-04-19 Ranjit Mathew <rmathew@hotmail.com> * java/io/File.java (getAbsolutePath): On Windows, take care diff --git a/libjava/java/math/BigDecimal.java b/libjava/java/math/BigDecimal.java index a4a4a56..fc99cf1 100644 --- a/libjava/java/math/BigDecimal.java +++ b/libjava/java/math/BigDecimal.java @@ -431,6 +431,11 @@ public class BigDecimal extends Number implements Comparable return scale; } + public BigInteger unscaledValue() + { + return intVal; + } + public BigDecimal abs () { return new BigDecimal (intVal.abs (), scale); diff --git a/libjava/java/math/BigInteger.java b/libjava/java/math/BigInteger.java index 6f919f7..34ec5a4 100644 --- a/libjava/java/math/BigInteger.java +++ b/libjava/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) { |