summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-05-20 13:41:33 +0000
committerPaul Phillips <paulp@improving.org>2010-05-20 13:41:33 +0000
commit4debc5bf1e89a8cb185fd7af1adf1c81c0e95e0c (patch)
tree9dc3caafe53cd9e88fd59ac865c64a40a4ae3b38 /src
parentb96804031a11f36ae00acc3020a7ed338b926abe (diff)
downloadscala-4debc5bf1e89a8cb185fd7af1adf1c81c0e95e0c.tar.gz
scala-4debc5bf1e89a8cb185fd7af1adf1c81c0e95e0c.tar.bz2
scala-4debc5bf1e89a8cb185fd7af1adf1c81c0e95e0c.zip
Fixed a BigDecimal/Long comparison bug reported...
Fixed a BigDecimal/Long comparison bug reported on the list. No review.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/math/BigDecimal.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index b8dbe03db0..7312c0d2c0 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -178,9 +178,10 @@ extends ScalaNumber with ScalaNumericConversions
/** Compares this BigDecimal with the specified value for equality.
*/
override def equals (that: Any): Boolean = that match {
- case that: BigDecimal => this equals that
- case that: BigInt => this.toBigIntExact exists (that equals _)
- case x => (this <= BigDecimal.MaxLong && this >= BigDecimal.MinLong) && unifiedPrimitiveEquals(x)
+ case that: BigDecimal => this equals that
+ case that: BigInt => this.toBigIntExact exists (that equals _)
+ case _: Float | _: Double => unifiedPrimitiveEquals(that)
+ case x => isWhole && this <= BigDecimal.MaxLong && this >= BigDecimal.MinLong && unifiedPrimitiveEquals(x)
}
protected[math] def isWhole = (this remainder 1) == BigDecimal(0)