The _math
operator can be used to run javascript Math
methods.
The _math
operator can take arguments in the following forms:
No Arguments
(void): number
Some methods like _math.PI
take no arguments:
_math.PI: null
Returns: pi
Single argument
(x: number): number
Some methods like _math.round
take a single argument:
_math.round: 3.14
Returns: 3
Named arguments
({x: number, y: number}): number
([x: number, y: number]): number
Some methods like _math.pow
take an object with named arguments:
_math.pow:
base: 2
exponent: 3
Returns: 8
These methods also accept their arguments as an array:
_math.pow:
- 2
- 3
Returns: 8
Array arguments
(values: number[]): number
Some methods like _math.max
take an array of values as arguments:
_math.max:
- 42
- 99
- 0
Returns: 99
Operator methods:
_math.abs
(x: number): number
The _math.abs
method returns the absolute value of a number.
_math.acos
(x: number): number
The _math.acos
method returns the arccosine (in radians) of a number.
_math.acosh
(x: number): number
The _math.acosh
method returns the hyperbolic arc-cosine of a number.
_math.asin
(x: number): number
The _math.asin
method returns the arcsine (in radians) of a number.
_math.atan
(x: number): number
The _math.atan
method returns the arctangent (in radians) of a number.
_math.atan2
({x: number, y: number}): number
([x: number, y: number]): number
The _math.atan2
method returns the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y).
_math.atanh
(x: number): number
The _math.atanh
method returns the hyperbolic arctangent of a number.
_math.cbrt
(x: number): number
The _math.cbrt
method returns the returns the cube root of a number.
_math.ceil
(x: number): number
The _math.ceil
method rounds a number up to the next largest integer.
_math.clz32
(x: number): number
The _math.clz32
method returns the number of leading zero bits in the 32-bit binary representation of a number.
_math.cos
(x: number): number
The _math.cos
method returns the cosine of the specified angle, which must be specified in radians
_math.cosh
(x: number): number
The _math.cosh
method returns the hyperbolic cosine of a number.
_math.exp
(x: number): number
The _math.exp
method returns e
(Euler's number) to the power x
.
_math.expm1
(x: number): number
The _math.expm1
method returns e
(Euler's number) to the power x
minus 1
.
_math.floor
(x: number): number
The _math.floor
method returns the largest integer less than or equal to a given number.
_math.fround
(x: number): number
The _math.fround
method returns the nearest 32-bit single precision float representation of a number.
_math.hypot
(values: number[]): number
The _math.hypot
method returns the square root of the sum of squares of its arguments.
_math.imul
({a: number, b: number}): number
([a: number, b: number]): number
The _math.imul
method returns the result of the C-like 32-bit multiplication of the two parameters.
_math.log
(x: number): number
The _math.log
method returns the natural logarithm (base e
) of a number.
_math.log10
(x: number): number
The _math.log10
method returns the base 10
logarithm of a number.
_math.log1p
(x: number): number
The _math.log1p
method returns the natural logarithm (base e) of 1 + a number
.
_math.log2
(x: number): number
The _math.log2
method returns the base 2
logarithm of a number.
_math.max
(values: number[]): number
The _math.max
method returns the largest of the numbers given as input parameters.
_math.min
(values: number[]): number
The _math.min
method returns the smallest of the numbers given as input parameters.
_math.pow
({base: number, exponent: number}): number
([base: number, exponent: number]): number
The _math.pow
method returns the base
to the exponent
power.
_math.random
(void): number
The _math.random
method returns a floating-point, pseudo-random number in the range 0
to less than 1
.
_math.round
(x: number): number
The _math.round
method returns the value of a number rounded to the nearest integer.
_math.sign
(x: number): number
The _math.sign
method returns either a positive or negative 1 (+/- 1
), indicating the sign of a number passed into the argument.
_math.sin
(x: number): number
The _math.sin
method returns the sine of a number.
_math.sinh
(x: number): number
The _math.sinh
method returns the hyperbolic sine of a number.
_math.sqrt
(x: number): number
The _math.sqrt
method returns the square root of a number.
_math.tan
(x: number): number
The _math.tan
method returns the tangent of a number.
_math.trunc
(x: number): number
The _math.trunc
method returns the integer part of a number by removing any fractional digits.
_math.E
(void): number
The _math.E
method returns Euler's number, the base of natural logarithms, e
, which is approximately 2.718.
_math.LN10
(void): number
The _math.LN10
method returns the natural logarithm of 10
, which is approximately 2.302.
_math.LN2
(void): number
The _math.LN2
method returns the natural logarithm of 2
, which is approximately 0.693.
_math.LOG10E
(void): number
The _math.LOG10E
method returns the base 10
logarithm of e
, which is approximately 0.434.
_math.LOG2E
(void): number
The _math.LOG2E
method returns the base 2
logarithm of e
, which is approximately 1.442.
_math.PI
(void): number
The _math.PI
method returns the constant pi
, the ratio of the circumference of a circle to its diameter, which is approximately 3.14159.
_math.SQRT1_2
(void): number
The _math.SQRT1_2
method returns the square root of 1/2
, which is approximately 0.707.
_math.SQRT2
(void): number
The _math.SQRT2
method returns the square root of 2
, which is approximately 1.414.