Pages
core

Search
Entities

# Math

## Functions

abs
(
number
:
Number
)
:
Number

Returns the absolute value of the given number.

``````Math.abs(1) == 1
Math.abs(-1) == 1
``````
acos
(
number
:
Number
)
:
Number

Returns the inverse cosine of the given angle in radians

acosh
(
number
:
Number
)
:
Number

Returns the inverse hyperbolic cosine of the given angle in radians

asin
(
number
:
Number
)
:
Number

Returns the inverse sine of the given angle in radians

asinh
(
number
:
Number
)
:
Number

Returns the inverse hyperbolic sine of the given angle in radians

atan
(
number
:
Number
)
:
Number

Returns the inverse tangent of the given angle in radians

atan2
(
y
:
Number
x
:
Number
)
:
Number

Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y)

atanh
(
number
:
Number
)
:
Number

Returns the inverse hyperbolic tangent of the given angle in radians

cbrt
(
number
:
Number
)
:
Number

Returns the cubic root of the given number

``````Math.cbrt(1) == 1
Math.cbrt(64) == 4
``````
ceil
(
number
:
Number
)
:
Number

Returns the smallest integer greater than or equal to the given number.

``````Math.ceil(0.3) == 1
``````
clamp
(
value
:
Number
lower
:
Number
upper
:
Number
)
:
Number

Clamps the given number between the given upper and lower bounds.

``````Math.clamp(100, 0, 10) == 10
Math.clamp(-100, 0, 10) == 0
``````
clz32
(
number
:
Number
)
:
Number

Returns the number of leading zero bits in the 32-bit binary representation of a number

00000000000000000000000000000100 Math.clz32(4) == 29

cos
(
number
:
Number
)
:
Number

Returns the cosine of the given angle in radians

cosh
(
number
:
Number
)
:
Number

Returns the hyperbolic cosine of the given angle in radians

exp
(
x
:
Number
)
:
Number

Returns the value of `Math:E` raised to the power x, where x is the given number

expm1
(
x
:
Number
)
:
Number

Returns the value of `Math:E` to the power x, minus 1

``````Math.exp(2) == 7.38905609893065
Math.expm1(2) == 6.38905609893065
``````
floor
(
number
:
Number
)
:
Number

Returns the largest integer less than or equal to the given number.

``````Math.floor(0.8) == 0
``````
fmod
(
a
:
Number
b
:
Number
)
:
Number

Returns the floating-point remainder of two numbers.

``````Math.fmod(2, 5.3) == 1.3
Math.fmod(4.2, 18.5) == 1.7
``````
fround
(
number
:
Number
)
:
Number

Returns the nearest 32-bit single precision float representation of the given number.

hypot
(
a
:
Number
b
:
Number
)
:
Number

Returns the square root of the sum of squares of its arguments.

``````Math.hypot(3, 4) == 5
``````
imul
(
a
:
Number
b
:
number
)
:
Number

Returns the result using C-like 32-bit multiplication of the two parameters.

``````Math.imul(3, 4) == 12
``````
log
(
number
:
Number
)
:
Number

Returns natural logarithm (base e) of the given value

``````Math.log(1) == 0
``````
log10
(
number
:
Number
)
:
Number

Returns natural logarithm (base 10) of the given value

``````Math.log10(100) == 10
``````
log1p
(
number
:
Number
)
:
Number

Returns natural logarithm (base e) of the given value, plus 1

``````Math.log1p(1) == 0
``````
log2
(
number
:
Number
)
:
Number

Returns natural logarithm (base 2) of the given value

``````Math.log2(8) == 3
``````
max
(
number1
:
Number
number2
:
Number
)
:
Number

Returns the highest-valued number from the arguments.

``````Math.max(1, 2) == 2
``````
min
(
number1
:
Number
number2
:
Number
)
:
Number

Returns the lowest-valued number from the arguments.

``````Math.min(1, 2) == 1
``````
negate
(
number
:
Number
)
:
Number

Negates the given number.

``````Math.negate(1) == -1
``````
pow
(
value
:
Number
exponent
:
Number
)
:
Number

Returns the exponent power of the given number.

``````Math.pow(2, 2) == 4
``````
random
:
Number

Returns a pseudo-random number in the range 0 to less than 1.

round
(
number
:
Number
)
:
Number

Returns the value of a number rounded to the nearest integer.

``````Math.round(0.5) == 1
``````
sign
(
number
:
Number
)
:
Number

Returns the sign of the given number (1 or -1)

``````Math.sign(5) == 1
Math.sign(-5) == -1
``````
sin
(
value
:
Number
)
:
Number

Calculates the sine of the given angle in radians

sinh
(
number
:
Number
)
:
Number

Calculates the hyperbolic sine of the given angle in radians

sqrt
(
value
:
Number
)
:
Number

Returns the square root of the given number

``````Math.sqrt(4) == 2
``````
tan
(
number
:
Number
)

Calculates the tangent of the given angle in radians

tanh
(
number
:
Number
)
:
Number

Calculates the hyperbolic tangent of the given angle in radians

trunc
(
number
:
Number
)

Returns the integer part of a number by removing any fractional digits.

``````Math.trunc(13.37) == 13
Math.trunc(42.84) == 42
``````
truncate
(
value
:
Number
to
:
Number
)
:
Number

Truncates the given number to the given amount.

``````Math.truncate(0.123456, 2) == 0.12
``````