From 4debc5bf1e89a8cb185fd7af1adf1c81c0e95e0c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 20 May 2010 13:41:33 +0000 Subject: Fixed a BigDecimal/Long comparison bug reported... Fixed a BigDecimal/Long comparison bug reported on the list. No review. --- src/library/scala/math/BigDecimal.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') 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) -- cgit v1.2.3