diff options
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/math/BigDecimal.java | 5 | ||||
-rw-r--r-- | libjava/java/math/BigInteger.java | 17 |
2 files changed, 22 insertions, 0 deletions
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) { |