diff options
author | Dominik Gruntz <dominik.gruntz@fhnw.ch> | 2012-07-05 23:49:39 +0200 |
---|---|---|
committer | Dominik Gruntz <dominik.gruntz@fhnw.ch> | 2012-07-05 23:49:39 +0200 |
commit | efc6854f7df46a479cbdd2c40e777edd6ee36d33 (patch) | |
tree | 3d1097375bba276ef659cbe207f607b63e5366ff /src/library | |
parent | 171a1d8bc859947d80d4728c251abe330dbe9802 (diff) | |
download | scala-efc6854f7df46a479cbdd2c40e777edd6ee36d33.tar.gz scala-efc6854f7df46a479cbdd2c40e777edd6ee36d33.tar.bz2 scala-efc6854f7df46a479cbdd2c40e777edd6ee36d33.zip |
SI-6033 Closed. Provides implicit conversion from java.math.BigInteger to BigInt
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/math/BigInt.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala index af2ab04576..4471e417d9 100644 --- a/src/library/scala/math/BigInt.scala +++ b/src/library/scala/math/BigInt.scala @@ -87,6 +87,11 @@ object BigInt { def apply(x: String, radix: Int): BigInt = new BigInt(new BigInteger(x, radix)) + /** Translates a `java.math.BigInteger` into a BigInt. + */ + def apply(x: BigInteger): BigInt = + new BigInt(x) + /** Returns a positive BigInt that is probably prime, with the specified bitLength. */ def probablePrime(bitLength: Int, rnd: scala.util.Random): BigInt = @@ -96,9 +101,13 @@ object BigInt { */ implicit def int2bigInt(i: Int): BigInt = apply(i) - /** Implicit conversion from long to BigInt + /** Implicit conversion from `Long` to `BigInt`. */ implicit def long2bigInt(l: Long): BigInt = apply(l) + + /** Implicit conversion from `java.math.BigInteger` to `scala.BigInt`. + */ + implicit def javaBigInteger2bigInt(x: BigInteger): BigInt = apply(x) } /** |