summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2006-12-19 12:33:10 +0000
committermichelou <michelou@epfl.ch>2006-12-19 12:33:10 +0000
commit5384cea22b2315184e13b95f98b6711cf029f3e8 (patch)
treeb15634eb6f96b7ae449b38f962d265bad7e4cd4c
parenteabd3ebf0ce7dc8a8e46b514a9166c5a17662085 (diff)
downloadscala-5384cea22b2315184e13b95f98b6711cf029f3e8.tar.gz
scala-5384cea22b2315184e13b95f98b6711cf029f3e8.tar.bz2
scala-5384cea22b2315184e13b95f98b6711cf029f3e8.zip
added Scala comments to scala/Math.scala
-rw-r--r--src/library/scala/Math.scala72
1 files changed, 71 insertions, 1 deletions
diff --git a/src/library/scala/Math.scala b/src/library/scala/Math.scala
index aa74c67e67..23bb4e73ce 100644
--- a/src/library/scala/Math.scala
+++ b/src/library/scala/Math.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -11,11 +11,26 @@
package scala
+/** The object <code>Math</code> contains methods for performing basic numeric
+ * operations such as the elementary exponential, logarithm, square root, and
+ * trigonometric functions.
+ */
object Math {
+ /** The <code>double</code> value that is closer than any other to
+ * <code>e</code>, the base of the natural logarithms.
+ */
val E = java.lang.Math.E
+
+ /** The <code>double</code> value that is closer than any other to
+ * <code>pi</code>, the ratio of the circumference of a circle to its
+ * diameter.
+ */
val Pi = java.lang.Math.PI
+ /** Returns a <code>double</code> value with a positive sign, greater than
+ * or equal to <code>0.0</code> and less than <code>1.0</code>.
+ */
def random: Double = java.lang.Math.random()
def sin(x: Double): Double = java.lang.Math.sin(x)
@@ -24,17 +39,72 @@ object Math {
def asin(x: Double): Double = java.lang.Math.asin(x)
def acos(x: Double): Double = java.lang.Math.acos(x)
def atan(x: Double): Double = java.lang.Math.atan(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 <code>x</code> in radians.
+ */
def toRadians(x: Double): Double = java.lang.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 <code>x</code> in degrees.
+ */
def toDegrees(x: Double): Double = java.lang.Math.toDegrees(x)
+
+ /** Returns Euler's number <code>e</code> raised to the power of a
+ * <code>double</code> value.
+ *
+ * @param x the exponent to raise <code>e</code> to.
+ * @return the value <code>e<sup>a</sup></code>, where <code>e</code>
+ * is the base of the natural logarithms.
+ */
def exp(x: Double): Double = java.lang.Math.exp(x)
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)
+
+ /** Returns the <code>double</code> value that is closest in value to the
+ * argument and is equal to a mathematical integer.
+ *
+ * @param x a <code>double</code> value
+ * @return the closest floating-point value to a that is equal to a
+ * mathematical integer.
+ */
def rint(x: Double): Double = java.lang.Math.rint(x)
+
+ /** Converts rectangular coordinates <code>(x, y)</code> to polar
+ * <code>(r, theta)</code>.
+ *
+ * @param x the ordinate coordinate
+ * @param y the abscissa coordinate
+ * @return the <em>theta</em> component of the point <code>(r, theta)</code>
+ * in polar coordinates that corresponds to the point
+ * <code>(x, y)</code> in Cartesian coordinates.
+ */
def atan2(x: Double, y: Double): Double = java.lang.Math.atan2(x, y)
+
+ /** Returns the value of the first argument raised to the power of the
+ * second argument.
+ *
+ * @param x the base.
+ * @param y the exponent.
+ * @return the value <code>x<sup>y</sup></code>.
+ */
def pow(x: Double, y: Double): Double = java.lang.Math.pow(x, y)
+
+ /** Returns the closest <code>long</code> to the argument.
+ *
+ * @param x a floating-point value to be rounded to a <code>long</code>.
+ * @return the value of the argument rounded to the nearest
+ * <code>long</code> value.
+ */
def round(x: Float): Int = java.lang.Math.round(x)
def round(x: Double): Long = java.lang.Math.round(x)
def abs(x: Int): Int = java.lang.Math.abs(x)