diff options
author | Jerry Quinn <jlquinn@optonline.net> | 2003-04-19 19:26:41 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-04-19 19:26:41 +0000 |
commit | afd4910af1eeaa5bd13bed450d81761e6fb5bcca (patch) | |
tree | 5ce1e52bab1d482436dcacc2d92fc543280208e0 | |
parent | f1a1591b9ef91e138109a510a92c60ee153b8555 (diff) | |
download | gcc-afd4910af1eeaa5bd13bed450d81761e6fb5bcca.zip gcc-afd4910af1eeaa5bd13bed450d81761e6fb5bcca.tar.gz gcc-afd4910af1eeaa5bd13bed450d81761e6fb5bcca.tar.bz2 |
BigInteger.java (probablePrime): New.
2003-04-19 Jerry Quinn <jlquinn@optonline.net>
* java/math/BigInteger.java (probablePrime): New.
* java/math/BigDecimal.java (unscaledValue): New.
From-SVN: r65825
-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) { |