summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2016-02-10 21:40:08 +0100
committerLukas Rytz <lukas.rytz@typesafe.com>2016-02-10 21:40:08 +0100
commitaa18beccff3b2f2680575c02f30467be0a557f13 (patch)
tree014ffb8174f3165c6450f49283e47ba219e342da /src
parent78c378c97c51600cac1cf42edd050aceb2366026 (diff)
parente5517e67eea79fbbd886110ff6dc993842852cf8 (diff)
downloadscala-aa18beccff3b2f2680575c02f30467be0a557f13.tar.gz
scala-aa18beccff3b2f2680575c02f30467be0a557f13.tar.bz2
scala-aa18beccff3b2f2680575c02f30467be0a557f13.zip
Merge pull request #4924 from ShaneDelmore/SI-9452
SI-9452: Extend BigDecimal with Ordered for java interop
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/math/BigDecimal.scala18
-rw-r--r--src/library/scala/math/BigInt.scala23
2 files changed, 7 insertions, 34 deletions
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index 371fd59a93..e769dfb8cb 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -397,7 +397,7 @@ object BigDecimal {
* @version 1.1
*/
final class BigDecimal(val bigDecimal: BigDec, val mc: MathContext)
-extends ScalaNumber with ScalaNumericConversions with Serializable {
+extends ScalaNumber with ScalaNumericConversions with Serializable with Ordered[BigDecimal] {
def this(bigDecimal: BigDec) = this(bigDecimal, BigDecimal.defaultMathContext)
import BigDecimal.RoundingMode._
import BigDecimal.{decimal, binary, exact}
@@ -537,22 +537,6 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
*/
def compare (that: BigDecimal): Int = this.bigDecimal compareTo that.bigDecimal
- /** Less-than-or-equals comparison of BigDecimals
- */
- def <= (that: BigDecimal): Boolean = compare(that) <= 0
-
- /** Greater-than-or-equals comparison of BigDecimals
- */
- def >= (that: BigDecimal): Boolean = compare(that) >= 0
-
- /** Less-than of BigDecimals
- */
- def < (that: BigDecimal): Boolean = compare(that) < 0
-
- /** Greater-than comparison of BigDecimals
- */
- def > (that: BigDecimal): Boolean = compare(that) > 0
-
/** Addition of BigDecimals
*/
def + (that: BigDecimal): BigDecimal = new BigDecimal(this.bigDecimal add that.bigDecimal, mc)
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala
index abc7371d9f..3ae3b9bf6c 100644
--- a/src/library/scala/math/BigInt.scala
+++ b/src/library/scala/math/BigInt.scala
@@ -109,7 +109,12 @@ object BigInt {
* @author Martin Odersky
* @version 1.0, 15/07/2003
*/
-final class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
+final class BigInt(val bigInteger: BigInteger)
+ extends ScalaNumber
+ with ScalaNumericConversions
+ with Serializable
+ with Ordered[BigInt]
+{
/** Returns the hash code for this BigInt. */
override def hashCode(): Int =
if (isValidLong) unifiedPrimitiveHashcode()
@@ -176,22 +181,6 @@ final class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNum
*/
def compare (that: BigInt): Int = this.bigInteger.compareTo(that.bigInteger)
- /** Less-than-or-equals comparison of BigInts
- */
- def <= (that: BigInt): Boolean = compare(that) <= 0
-
- /** Greater-than-or-equals comparison of BigInts
- */
- def >= (that: BigInt): Boolean = compare(that) >= 0
-
- /** Less-than of BigInts
- */
- def < (that: BigInt): Boolean = compare(that) < 0
-
- /** Greater-than comparison of BigInts
- */
- def > (that: BigInt): Boolean = compare(that) > 0
-
/** Addition of BigInts
*/
def + (that: BigInt): BigInt = new BigInt(this.bigInteger.add(that.bigInteger))