summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/math/Numeric.scala4
-rw-r--r--test/files/jvm/si5471.check2
-rw-r--r--test/files/jvm/si5471.scala17
3 files changed, 21 insertions, 2 deletions
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala
index 1f4e3c9865..ee62706e49 100644
--- a/src/library/scala/math/Numeric.scala
+++ b/src/library/scala/math/Numeric.scala
@@ -36,8 +36,8 @@ object Numeric {
def fromInt(x: Int): BigInt = BigInt(x)
def toInt(x: BigInt): Int = x.intValue
def toLong(x: BigInt): Long = x.longValue
- def toFloat(x: BigInt): Float = x.longValue.toFloat
- def toDouble(x: BigInt): Double = x.longValue.toDouble
+ def toFloat(x: BigInt): Float = x.floatValue
+ def toDouble(x: BigInt): Double = x.doubleValue
}
implicit object BigIntIsIntegral extends BigIntIsIntegral with Ordering.BigIntOrdering
diff --git a/test/files/jvm/si5471.check b/test/files/jvm/si5471.check
new file mode 100644
index 0000000000..bb101b641b
--- /dev/null
+++ b/test/files/jvm/si5471.check
@@ -0,0 +1,2 @@
+true
+true
diff --git a/test/files/jvm/si5471.scala b/test/files/jvm/si5471.scala
new file mode 100644
index 0000000000..2c8c4205c5
--- /dev/null
+++ b/test/files/jvm/si5471.scala
@@ -0,0 +1,17 @@
+
+object Test {
+
+ def main(args: Array[String]) {
+ import scala.math.Numeric
+ import scala.math.Numeric.Implicits._
+
+ val b = BigInt(Long.MaxValue) + 1
+
+ def dbl[N :Numeric](n: N) = n.toDouble
+ def flt[N :Numeric](n: N) = n.toFloat
+
+ println(dbl(b) == b.toDouble)
+ println(flt(b) == b.toFloat)
+ }
+
+}