Pages
Standard Library

Search
Entities

# Math

## Functions

abs
(
number
:
Number
)
:
Number

Returns the absolute value of the given number.

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

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

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

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

``````Math.clamp(0, 10, 100) == 10
Math.clamp(0, 10, -100) == 0
``````
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(5.3, 2) == 1.3
Math.fmod(18.5, 4.2) == 1.7
``````
max
(
number1
:
Number
number2
:
Number
)
:
Number

Returns the highest-valued number from the arguments.

``````Math.min(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
(
exponent
:
Number
value
:
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
``````
sqrt
(
value
:
Number
)
:
Number

Returns the square root of the given number

``````Math.sqrt(4) == 2
``````
truncate
(
to
:
Number
value
:
Number
)
:
Number

Truncates the given number to the given amount.

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