From e0eb99500c5fd1304cd03c95331403fbba8954e3 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Tue, 24 Apr 2007 15:56:55 +0000 Subject: Deprecated scala.compat.Math and move some memb... Deprecated scala.compat.Math and move some members to scala.Math and scala.runtime.Rich{Float,Double} --- src/library/scala/Math.scala | 52 ++++++++++++++++++++++++++++++ src/library/scala/compat/Math.scala | 5 ++- src/library/scala/runtime/RichDouble.scala | 18 +++++++++++ src/library/scala/runtime/RichFloat.scala | 18 +++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/library/scala/Math.scala b/src/library/scala/Math.scala index 23bb4e73ce..3699b48811 100644 --- a/src/library/scala/Math.scala +++ b/src/library/scala/Math.scala @@ -17,6 +17,57 @@ package scala */ object Math { + /** The smalles possible value for scala.Byte. */ + val MIN_BYTE = java.lang.Byte.MIN_VALUE + /** The greatest possible value for scala.Byte. */ + val MAX_BYTE = java.lang.Byte.MAX_VALUE + + /** The smalles possible value for scala.Short. */ + val MIN_SHORT = java.lang.Short.MIN_VALUE + /** The greatest possible value for scala.Short. */ + val MAX_SHORT = java.lang.Short.MAX_VALUE + + /** The smalles possible value for scala.Char. */ + val MIN_CHAR = java.lang.Character.MIN_VALUE + /** The greatest possible value for scala.Char. */ + val MAX_CHAR = java.lang.Character.MAX_VALUE + + /** The smalles possible value for scala.Int. */ + val MIN_INT = java.lang.Integer.MIN_VALUE + /** The greatest possible value for scala.Int. */ + val MAX_INT = java.lang.Integer.MAX_VALUE + + /** The smalles possible value for scala.Long. */ + val MIN_LONG = java.lang.Long.MIN_VALUE + /** The greatest possible value for scala.Long. */ + val MAX_LONG = java.lang.Long.MAX_VALUE + + /** The smalles possible value for scala.Float. */ + val MIN_FLOAT = -java.lang.Float.MAX_VALUE + /** The smalles difference between two values of scala.Float. */ + val EPS_FLOAT = java.lang.Float.MIN_VALUE + /** The greatest possible value for scala.Float. */ + val MAX_FLOAT = java.lang.Float.MAX_VALUE + /** A value of type scala.Float that represents no number. */ + val NaN_FLOAT = java.lang.Float.NaN + /** Negative infinity of type scala.Float*/ + val NEG_INF_FLOAT = java.lang.Float.NEGATIVE_INFINITY + /** Positive infinity of type scala.Float*/ + val POS_INF_FLOAT = java.lang.Float.POSITIVE_INFINITY + + /** The smalles possible value for scala.Double. */ + val MIN_DOUBLE = -java.lang.Double.MAX_VALUE + /** The smalles difference between two values of scala.Double. */ + val EPS_DOUBLE = java.lang.Double.MIN_VALUE + /** The greatest possible value for scala.Double. */ + val MAX_DOUBLE = java.lang.Double.MAX_VALUE + /** A value of type scala.Double that represents no number. */ + val NaN_DOUBLE = java.lang.Double.NaN + /** Negative infinity of type scala.Double*/ + val NEG_INF_DOUBLE = java.lang.Double.NEGATIVE_INFINITY + /** Positive infinity of type scala.Double*/ + val POS_INF_DOUBLE = java.lang.Double.POSITIVE_INFINITY + /** The double value that is closer than any other to * e, the base of the natural logarithms. */ @@ -67,6 +118,7 @@ object Math { def log(x: Double): Double = java.lang.Math.log(x) def sqrt(x: Double): Double = java.lang.Math.sqrt(x) def IEEEremainder(x: Double, y: Double): Double = java.lang.Math.IEEEremainder(x, y) + def ceil(x: Double): Double = java.lang.Math.ceil(x) def floor(x: Double): Double = java.lang.Math.floor(x) diff --git a/src/library/scala/compat/Math.scala b/src/library/scala/compat/Math.scala index 183d2aa09d..5cd337901c 100644 --- a/src/library/scala/compat/Math.scala +++ b/src/library/scala/compat/Math.scala @@ -11,7 +11,10 @@ package scala.compat; - +/** + * This class will be removed soon. Use scala.Math instead + */ +@deprecated object Math { val MIN_BYTE = java.lang.Byte.MIN_VALUE val MAX_BYTE = java.lang.Byte.MAX_VALUE diff --git a/src/library/scala/runtime/RichDouble.scala b/src/library/scala/runtime/RichDouble.scala index c4bd0c589f..a091302f51 100644 --- a/src/library/scala/runtime/RichDouble.scala +++ b/src/library/scala/runtime/RichDouble.scala @@ -25,6 +25,24 @@ final class RichDouble(x: Double) extends Proxy with Ordered[Double] { def abs: Double = Math.abs(x) def round: Long = Math.round(x) + def ceil: Double = Math.ceil(x) + def floor: Double = Math.floor(x) + + /** Converts an angle measured in degrees to an approximately equivalent + * angle measured in radians. + * + * @param x an angle, in degrees + * @return the measurement of the angle x in radians. + */ + def toRadians: Double = Math.toRadians(x) + + /** Converts an angle measured in radians to an approximately equivalent + * angle measured in degrees. + * + * @param x angle, in radians + * @return the measurement of the angle x in degrees. + */ + def toDegrees: Double = Math.toDegrees(x) // isNaN is provided by the implicit conversion to java.lang.Double // def isNaN: Boolean = java.lang.Double.isNaN(x) diff --git a/src/library/scala/runtime/RichFloat.scala b/src/library/scala/runtime/RichFloat.scala index 65e24c6363..11b2661b7c 100644 --- a/src/library/scala/runtime/RichFloat.scala +++ b/src/library/scala/runtime/RichFloat.scala @@ -25,6 +25,24 @@ final class RichFloat(x: Float) extends Proxy with Ordered[Float] { def abs: Float = Math.abs(x) def round: Int = Math.round(x) + def ceil: Float = Math.ceil(x).toFloat + def floor: Float = Math.floor(x).toFloat + + /** Converts an angle measured in degrees to an approximately equivalent + * angle measured in radians. + * + * @param x an angle, in degrees + * @return the measurement of the angle x in radians. + */ + def toRadians: Float = Math.toRadians(x).toFloat + + /** Converts an angle measured in radians to an approximately equivalent + * angle measured in degrees. + * + * @param x angle, in radians + * @return the measurement of the angle x in degrees. + */ + def toDegrees: Float = Math.toDegrees(x).toFloat // isNaN is provided by the implicit conversion to java.lang.Float // def isNaN: Boolean = java.lang.Float.isNaN(x) -- cgit v1.2.3