diff options
-rw-r--r-- | src/library/scala/compat/Math.scala | 17 | ||||
-rw-r--r-- | src/library/scala/runtime/RichDouble.scala | 6 | ||||
-rw-r--r-- | src/library/scala/runtime/RichFloat.scala | 6 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/library/scala/compat/Math.scala b/src/library/scala/compat/Math.scala index de64dcc3c1..183d2aa09d 100644 --- a/src/library/scala/compat/Math.scala +++ b/src/library/scala/compat/Math.scala @@ -23,11 +23,22 @@ object Math { val MAX_INT = java.lang.Integer.MAX_VALUE val MIN_LONG = java.lang.Long.MIN_VALUE val MAX_LONG = java.lang.Long.MAX_VALUE - val MIN_FLOAT = java.lang.Float.MIN_VALUE - val MAX_FLOAT = java.lang.Float.MIN_VALUE - val MIN_DOUBLE = java.lang.Double.MIN_VALUE + + val MIN_FLOAT = -java.lang.Float.MAX_VALUE + val EPS_FLOAT = java.lang.Float.MIN_VALUE + val MAX_FLOAT = java.lang.Float.MAX_VALUE + val NaN_FLOAT = java.lang.Float.NaN + val NEG_INF_FLOAT = java.lang.Float.NEGATIVE_INFINITY + val POS_INF_FLOAT = java.lang.Float.POSITIVE_INFINITY + + val MIN_DOUBLE = -java.lang.Double.MAX_VALUE + val EPS_DOUBLE = java.lang.Double.MIN_VALUE val MAX_DOUBLE = java.lang.Double.MAX_VALUE + val NaN_DOUBLE = java.lang.Double.NaN + val NEG_INF_DOUBLE = java.lang.Double.NEGATIVE_INFINITY + val POS_INF_DOUBLE = java.lang.Double.POSITIVE_INFINITY + val E = java.lang.Math.E val PI = java.lang.Math.PI def min(x: Int, y: Int): Int = java.lang.Math.min(x, y) diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala index 59b992b5a5..a91b244214 100644 --- a/src/library/scala/runtime/RichDouble.scala +++ b/src/library/scala/runtime/RichDouble.scala @@ -20,4 +20,10 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { // Ordered[Double].compare def compare (y: Double): Int = if (x < y) -1 else if (x > y) 1 else 0 + // isNaN is provided by the implicit conversion to java.lang.Double + // def isNaN: Boolean = java.lang.Double.isNaN(x) + def isInfinity: Boolean = java.lang.Double.isInfinite(x) + def isPosInfinity: Boolean = isInfinity && x > 0.0 + def isNegInfinity: Boolean = isInfinity && x < 0.0 + } diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala index 9d6e034718..c5b7eba82f 100644 --- a/src/library/scala/runtime/RichFloat.scala +++ b/src/library/scala/runtime/RichFloat.scala @@ -20,4 +20,10 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { // Ordered[Float].compare def compare (y: Float): Int = if (x < y) -1 else if (x > y) 1 else 0 + // isNaN is provided by the implicit conversion to java.lang.Float + // def isNaN: Boolean = java.lang.Float.isNaN(x) + def isInfinity: Boolean = java.lang.Float.isInfinite(x) + def isPosInfinity: Boolean = isInfinity && x > 0.0f + def isNegInfinity: Boolean = isInfinity && x < 0.0f + } |