diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/math/package.scala | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/src/library/scala/math/package.scala b/src/library/scala/math/package.scala index 255955be67..9e90b77fc6 100644 --- a/src/library/scala/math/package.scala +++ b/src/library/scala/math/package.scala @@ -9,22 +9,60 @@ package scala /** The package object `scala.math` contains methods for performing basic - * numeric operations such as the elementary exponential, logarithm, - * square root, and trigonometric functions. - */ - + * numeric operations such as elementary exponential, logarithmic, root and + * trigonometric functions. + */ package object math extends MathCommon { - // These are new in 2.8, so they don't belong in the deprecated scala.Math. - def log10(x: Double): Double = java.lang.Math.log10(x) + // ----------------------------------------------------------------------- + // root functions + // ----------------------------------------------------------------------- + + /** Returns the cube root of the given `Double` value. */ def cbrt(x: Double): Double = java.lang.Math.cbrt(x) - def ulp(x: Double): Double = java.lang.Math.ulp(x) - def ulp(x: Float): Float = java.lang.Math.ulp(x) + // ----------------------------------------------------------------------- + // exponential functions + // ----------------------------------------------------------------------- + + /** Returns `exp(x) - 1`. */ + def expm1(x: Double): Double = java.lang.Math.expm1(x) + + // ----------------------------------------------------------------------- + // logarithmic functions + // ----------------------------------------------------------------------- + + /** Returns the natural logarithm of the sum of the given `Double` value and 1. */ + def log1p(x: Double): Double = java.lang.Math.log1p(x) + + /** Returns the base 10 logarithm of the given `Double` value. */ + def log10(x: Double): Double = java.lang.Math.log10(x) + + // ----------------------------------------------------------------------- + // trigonometric functions + // ----------------------------------------------------------------------- + + /** Returns the hyperbolic sine of the given `Double` value. */ def sinh(x: Double): Double = java.lang.Math.sinh(x) + + /** Returns the hyperbolic cosine of the given `Double` value. */ def cosh(x: Double): Double = java.lang.Math.cosh(x) + + /** Returns the hyperbolic tangent of the given `Double` value. */ def tanh(x: Double):Double = java.lang.Math.tanh(x) + + // ----------------------------------------------------------------------- + // miscellaneous functions + // ----------------------------------------------------------------------- + + /** Returns the square root of the sum of the squares of both given `Double` + * values without intermediate underflow or overflow. + */ def hypot(x: Double, y: Double): Double = java.lang.Math.hypot(x, y) - def expm1(x: Double): Double = java.lang.Math.expm1(x) - def log1p(x: Double): Double = java.lang.Math.log1p(x) + + /** Returns the size of an ulp of the given `Double` value. */ + def ulp(x: Double): Double = java.lang.Math.ulp(x) + + /** Returns the size of an ulp of the given `Float` value. */ + def ulp(x: Float): Float = java.lang.Math.ulp(x) } |