diff options
author | clhodapp <clhodapp1@gmail.com> | 2014-01-05 21:38:26 -0600 |
---|---|---|
committer | clhodapp <clhodapp1@gmail.com> | 2014-01-06 13:07:30 -0600 |
commit | b46d7aefd6eda36454cfd4cf339642e3c13c2022 (patch) | |
tree | 9359cafc6697ee0d7343b8ca3c6d19c1714dba21 /src | |
parent | 527fd9aea58cf5c1b8f638d0321a8d0947d2916a (diff) | |
download | scala-b46d7aefd6eda36454cfd4cf339642e3c13c2022.tar.gz scala-b46d7aefd6eda36454cfd4cf339642e3c13c2022.tar.bz2 scala-b46d7aefd6eda36454cfd4cf339642e3c13c2022.zip |
SI-8102 -0.0.abs must equal 0.0
SI-8102 points out that -0.0.abs returns -0.0 (in error). The same issue
exists for -0.0f. This commit fixes the issue for both by delegating to
math.abs.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/math/Numeric.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala index e6644c0dfc..eafbf96993 100644 --- a/src/library/scala/math/Numeric.scala +++ b/src/library/scala/math/Numeric.scala @@ -127,6 +127,8 @@ object Numeric { def toLong(x: Float): Long = x.toLong def toFloat(x: Float): Float = x def toDouble(x: Float): Double = x.toDouble + // logic in Numeric base trait mishandles abs(-0.0f) + override def abs(x: Float): Float = math.abs(x) } trait FloatIsFractional extends FloatIsConflicted with Fractional[Float] { def div(x: Float, y: Float): Float = x / y @@ -149,6 +151,8 @@ object Numeric { def toLong(x: Double): Long = x.toLong def toFloat(x: Double): Float = x.toFloat def toDouble(x: Double): Double = x + // logic in Numeric base trait mishandles abs(-0.0) + override def abs(x: Double): Double = math.abs(x) } trait DoubleIsFractional extends DoubleIsConflicted with Fractional[Double] { def div(x: Double, y: Double): Double = x / y |