summaryrefslogtreecommitdiff
path: root/java/math
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2003-04-19 19:25:24 +0000
committerTom Tromey <tromey@redhat.com>2003-04-19 19:25:24 +0000
commit33fa22900f43e7945c4fee835c24ed1adaa0479f (patch)
treee64bd2bef2d93dd13aaf9a8040a4b513048152ee /java/math
parent9f094a1d9ed277488452bf1088597594b0357951 (diff)
downloadclasspath-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')
-rw-r--r--java/math/BigDecimal.java5
-rw-r--r--java/math/BigInteger.java17
2 files changed, 22 insertions, 0 deletions
diff --git a/java/math/BigDecimal.java b/java/math/BigDecimal.java
index a4a4a560e..fc99cf1f7 100644
--- a/java/math/BigDecimal.java
+++ b/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/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)
{