Math
The Math
Class provides a comprehensive set of mathematical functions and constants for a wide range of mathematical operations. It includes well-known mathematical constants such as 'e' (the base of natural logarithms) and 'pi' (the ratio of a circle's circumference to its diameter). The Math Class also offers methods for tasks like rounding numbers, generating random values, and converting angles between degrees and radians.
Constants
Math.E
The constant representing the mathematical constant 'e,' the base of natural logarithms.
Math.PI
The constant representing the mathematical constant 'pi,' the ratio of the circumference of a circle to its diameter.
Math.DEGREES_TO_RADIANS
A constant for converting angles from degrees to radians.
Math.RADIANS_TO_DEGREES
A constant for converting angles from radians to degrees.
Methods
Math.round(a: number): number
Returns the closest long
to the argument a
, with ties rounding to positive infinity.
Math.random(): Double
Returns a random double
value with a positive sign, greater than or equal to 0.0 and less than 1.0.
Math.nextUp(num: number): number
Returns the floating-point value adjacent to the argument num
in the direction of positive infinity.
Math.nextDown(num: number): number
Returns the floating-point value adjacent to the argument num
in the direction of negative infinity.
Math.sqrt(num: number): double
Returns the square root of a number in a double.