scala

Math

object Math extends MathCommon

The object Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

Annotations
Deprecated

use the scala.math package object instead. (Example package object usage: scala.math.Pi )

Source
Math.scala
Linear Supertypes
MathCommon, AnyRef, Any
Ordering
1. Alphabetic
2. By inheritance
Inherited
1. Hide All
2. Show all
1. Math
2. MathCommon
3. AnyRef
4. Any
Visibility
1. Public
2. All

Value Members

1. def != (arg0: AnyRef): Boolean

Attributes
final
Definition Classes
AnyRef
2. def != (arg0: Any): Boolean

Test two objects for inequality.

Test two objects for inequality.

returns

true if !(this == that), false otherwise.

Attributes
final
Definition Classes
Any
3. def ## (): Int

Equivalent to x.hashCode except for boxed numeric types.

Equivalent to x.hashCode except for boxed numeric types. For numerics, it returns a hash value which is consistent with value equality: if two value type instances compare as true, then ## will produce the same hash value for each of them.

returns

a hash value consistent with ==

Attributes
final
Definition Classes
AnyRef → Any
4. def == (arg0: AnyRef): Boolean

Attributes
final
Definition Classes
AnyRef
5. def == (arg0: Any): Boolean

Test two objects for equality.

Test two objects for equality.

returns

true if the receiver object is equivalent to the argument; false otherwise.

Attributes
final
Definition Classes
Any
6. val E : Double

The double value that is closer than any other to e, the base of the natural logarithms.

The double value that is closer than any other to e, the base of the natural logarithms.

Definition Classes
MathCommon
7. def IEEEremainder (x: Double, y: Double): Double

Definition Classes
MathCommon
8. val Pi : Double

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

The double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

Definition Classes
MathCommon
9. def abs (x: Double): Double

Definition Classes
MathCommon
10. def abs (x: Float): Float

Definition Classes
MathCommon
11. def abs (x: Long): Long

Definition Classes
MathCommon
12. def abs (x: Int): Int

Definition Classes
MathCommon
13. def acos (x: Double): Double

Definition Classes
MathCommon
14. def asInstanceOf [T0] : T0

Cast the receiver object to be of type T0.

Cast the receiver object to be of type T0.

Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression 1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expression List(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested type.

returns

Attributes
final
Definition Classes
Any
15. def asin (x: Double): Double

Definition Classes
MathCommon
16. def atan (x: Double): Double

Definition Classes
MathCommon
17. def atan2 (y: Double, x: Double): Double

Converts rectangular coordinates (x, y) to polar (r, theta).

Converts rectangular coordinates (x, y) to polar (r, theta).

y

the abscissa coordinate

x

the ordinate coordinate

returns

the theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.

Definition Classes
MathCommon
18. def ceil (x: Double): Double

Definition Classes
MathCommon
19. def clone (): AnyRef

Create a copy of the receiver object.

Create a copy of the receiver object.

The default implementation of the clone method is platform dependent.

returns

a copy of the receiver object.

Attributes
protected[lang]
Definition Classes
AnyRef
Annotations
()
20. def cos (x: Double): Double

Definition Classes
MathCommon
21. def eq (arg0: AnyRef): Boolean

Tests whether the argument (arg0) is a reference to the receiver object (this).

Tests whether the argument (arg0) is a reference to the receiver object (this).

The eq method implements an equivalence relation on non-null instances of AnyRef, and has three additional properties:

• It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false.
• For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false.
• null.eq(null) returns true.

When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

returns

true if the argument is a reference to the receiver object; false otherwise.

Attributes
final
Definition Classes
AnyRef
22. def equals (arg0: Any): Boolean

The equality method for reference types.

The equality method for reference types. See equals in Any.

returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
AnyRef → Any
23. def exp (x: Double): Double

Returns Euler's number e raised to the power of a double value.

Returns Euler's number e raised to the power of a double value.

x

the exponent to raise e to.

returns

the value ea, where e is the base of the natural logarithms.

Definition Classes
MathCommon
24. def finalize (): Unit

Called by the garbage collector on the receiver object when there are no more references to the object.

Called by the garbage collector on the receiver object when there are no more references to the object.

The details of when and if the finalize method is invoked, as well as the interaction between finalize and non-local returns and exceptions, are all platform dependent.

Attributes
protected[lang]
Definition Classes
AnyRef
Annotations
()
25. def floor (x: Double): Double

Definition Classes
MathCommon
26. def getClass (): java.lang.Class[_ <: java.lang.Object]

A representation that corresponds to the dynamic class of the receiver object.

A representation that corresponds to the dynamic class of the receiver object.

The nature of the representation is platform dependent.

returns

a representation that corresponds to the dynamic class of the receiver object.

Attributes
final
Definition Classes
AnyRef
27. def hashCode (): Int

The hashCode method for reference types.

The hashCode method for reference types. See hashCode in Any.

returns

the hash code value for this object.

Definition Classes
AnyRef → Any
28. def isInstanceOf [T0] : Boolean

Test whether the dynamic type of the receiver object is T0.

Test whether the dynamic type of the receiver object is T0.

Note that the result of the test is modulo Scala's erasure semantics. Therefore the expression 1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the specified type.

returns

true if the receiver object is an instance of erasure of type T0; false otherwise.

Attributes
final
Definition Classes
Any
29. def log (x: Double): Double

Definition Classes
MathCommon
30. def max (x: Double, y: Double): Double

Definition Classes
MathCommon
31. def max (x: Float, y: Float): Float

Definition Classes
MathCommon
32. def max (x: Long, y: Long): Long

Definition Classes
MathCommon
33. def max (x: Int, y: Int): Int

Definition Classes
MathCommon
34. def min (x: Double, y: Double): Double

Definition Classes
MathCommon
35. def min (x: Float, y: Float): Float

Definition Classes
MathCommon
36. def min (x: Long, y: Long): Long

Definition Classes
MathCommon
37. def min (x: Int, y: Int): Int

Definition Classes
MathCommon
38. def ne (arg0: AnyRef): Boolean

Equivalent to !(this eq that).

Equivalent to !(this eq that).

returns

true if the argument is not a reference to the receiver object; false otherwise.

Attributes
final
Definition Classes
AnyRef
39. def notify (): Unit

Wakes up a single thread that is waiting on the receiver object's monitor.

Wakes up a single thread that is waiting on the receiver object's monitor.

Attributes
final
Definition Classes
AnyRef
40. def notifyAll (): Unit

Wakes up all threads that are waiting on the receiver object's monitor.

Wakes up all threads that are waiting on the receiver object's monitor.

Attributes
final
Definition Classes
AnyRef
41. def pow (x: Double, y: Double): Double

Returns the value of the first argument raised to the power of the second argument.

Returns the value of the first argument raised to the power of the second argument.

x

the base.

y

the exponent.

returns

the value xy.

Definition Classes
MathCommon
42. def random : Double

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

Definition Classes
MathCommon
43. def rint (x: Double): Double

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

x

a double value

returns

the closest floating-point value to a that is equal to a mathematical integer.

Definition Classes
MathCommon
44. def round (x: Double): Long

Definition Classes
MathCommon
45. def round (x: Float): Int

Returns the closest long to the argument.

Returns the closest long to the argument.

x

a floating-point value to be rounded to a long.

returns

the value of the argument rounded to the nearest long value.

Definition Classes
MathCommon
46. def signum (x: Int): Int

Definition Classes
MathCommon
47. def signum (x: Long): Long

Definition Classes
MathCommon
48. def signum (x: Float): Float

Definition Classes
MathCommon
49. def signum (x: Double): Double

Definition Classes
MathCommon
50. def sin (x: Double): Double

Definition Classes
MathCommon
51. def sqrt (x: Double): Double

Definition Classes
MathCommon
52. def synchronized [T0] (arg0: ⇒ T0): T0

Attributes
final
Definition Classes
AnyRef
53. def tan (x: Double): Double

Definition Classes
MathCommon
54. def toDegrees (x: Double): Double

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

x

returns

the measurement of the angle x in degrees.

Definition Classes
MathCommon
55. def toRadians (x: Double): Double

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

x

an angle, in degrees

returns

the measurement of the angle x in radians.

Definition Classes
MathCommon
56. def toString (): String

Creates a String representation of this object.

Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

returns

a String representation of the object.

Definition Classes
AnyRef → Any
57. def wait (): Unit

Attributes
final
Definition Classes
AnyRef
Annotations
()
58. def wait (arg0: Long, arg1: Int): Unit

Attributes
final
Definition Classes
AnyRef
Annotations
()
59. def wait (arg0: Long): Unit

Attributes
final
Definition Classes
AnyRef
Annotations
()
60. val EPS_DOUBLE : Double

The smallest difference between two values of scala.

The smallest difference between two values of scala.Double.

Annotations
Deprecated

61. val EPS_FLOAT : Float

The smallest difference between two values of scala.

The smallest difference between two values of scala.Float.

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

64. val MAX_DOUBLE : Double

The greatest possible value for scala.

The greatest possible value for scala.Double.

Annotations
Deprecated

65. val MAX_FLOAT : Float

The greatest possible value for scala.

The greatest possible value for scala.Float.

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

71. val MIN_DOUBLE : Double

The smallest possible value for scala.

The smallest possible value for scala.Double.

Annotations
Deprecated

72. val MIN_FLOAT : Float

The smallest possible value for scala.

The smallest possible value for scala.Float.

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

Annotations
Deprecated

76. val NEG_INF_DOUBLE : Double

Negative infinity of type scala.

Negative infinity of type scala.Double.

Annotations
Deprecated

77. val NEG_INF_FLOAT : Float

Negative infinity of type scala.

Negative infinity of type scala.Float.

Annotations
Deprecated

78. val NaN_DOUBLE : Double

A value of type scala.

A value of type scala.Double that represents no number.

Annotations
Deprecated

79. val NaN_FLOAT : Float

A value of type scala.

A value of type scala.Float that represents no number.

Annotations
Deprecated

80. val POS_INF_DOUBLE : Double

Positive infinity of type scala.

Positive infinity of type scala.Double.

Annotations
Deprecated

81. val POS_INF_FLOAT : Float

Positive infinity of type scala.

Positive infinity of type scala.Float.

Annotations
Deprecated