File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,8 @@ object Numeric {
127
127
def toLong (x : Float ): Long = x.toLong
128
128
def toFloat (x : Float ): Float = x
129
129
def toDouble (x : Float ): Double = x.toDouble
130
+ // logic in Numeric base trait mishandles abs(-0.0f)
131
+ override def abs (x : Float ): Float = math.abs(x)
130
132
}
131
133
trait FloatIsFractional extends FloatIsConflicted with Fractional [Float ] {
132
134
def div (x : Float , y : Float ): Float = x / y
@@ -149,6 +151,8 @@ object Numeric {
149
151
def toLong (x : Double ): Long = x.toLong
150
152
def toFloat (x : Double ): Float = x.toFloat
151
153
def toDouble (x : Double ): Double = x
154
+ // logic in Numeric base trait mishandles abs(-0.0)
155
+ override def abs (x : Double ): Double = math.abs(x)
152
156
}
153
157
trait DoubleIsFractional extends DoubleIsConflicted with Fractional [Double ] {
154
158
def div (x : Double , y : Double ): Double = x / y
Original file line number Diff line number Diff line change
1
+
2
+
3
+ import org .junit .Assert ._
4
+ import org .junit .Test
5
+ import org .junit .runner .RunWith
6
+ import org .junit .runners .JUnit4
7
+
8
+ @ RunWith (classOf [JUnit4 ])
9
+ class NumericTest {
10
+
11
+ /* Test for SI-8102 */
12
+ @ Test
13
+ def testAbs {
14
+ assertTrue(- 0.0 .abs equals 0.0 )
15
+ assertTrue(- 0.0f .abs equals 0.0f )
16
+ }
17
+ }
18
+
You can’t perform that action at this time.
0 commit comments