Skip to content

Math Functions

Before going in note that any time VARNAME or FUNCNAME is written, it means a variable or function in the form Collection@Variable or a literal. Types are annotated in the parenthesis, for example (num) is a number, and (_) is any type.

Math Operators

Addition

Syntax:

VARNAME1z(num) = VARNAME2(num) + VARNAME3(num)
Returns the sum of VARNAME2 and VARNAME3 and assigns it to VARNAME1.

Subtraction

Syntax:

VARNAME1(num) = VARNAME2(num) - VARNAME3(num)

Returns the difference of VARNAME2 and VARNAME3 and assigns it to VARNAME1.

Multiplication

Syntax:

VARNAME1(num) = VARNAME2(num) * VARNAME3(num)

Returns the product of VARNAME2 and VARNAME3 and assigns it to VARNAME1.

Division

Syntax:

VARNAME1(num) = VARNAME2(num) / VARNAME3(num)

Returns the quotient of VARNAME2 and VARNAME3 and assigns it to VARNAME1.

Exponentiation

Syntax:

VARNAME1(num) = VARNAME2(num) ^ VARNAME3(num)

Returns VARNAME2 raised to the power of VARNAME3 and assigns it to VARNAME1.

Math Functions

abs

Syntax:

VARNAME1(num) = abs(VARNAME2(num))

Returns the absolute value of VARNAME2 and assigns it to VARNAME1.

nthroot

Syntax:

VARNAME1(num) = nthroot(VARNAME2(num), VARNAME3(num))

Returns the nth root of VARNAME2 where n is VARNAME3 and assigns it to VARNAME1.

rng

Syntax:

VARNAME1(str) = rng()

See rand() function for details

rand

Syntax:

VARNAME1(tup) = rand(VARNAME2(num), VARNAME3(num), VARNAME4(str))

Returns a tuple of a random decimal number between VARNAME2 and VARNAME3, and a modified RNG state for the next call and assigns it to VARNAME1. The RNG state is first created with rune VARNAME1 = rng() and then fed into VARNAME4 each time. This functions as both a seed generated with rng() and then shared between each rand() call, and the current number the RNG state is on, allowing for determinstic results. For example:

1
2
3
4
5
6
state = rng()
randomresult = rand(0, 100, state)
state = get(randomresult, 1)
randomnum = get(randomresult, 0)

randomresult2 = rand(0, 100, state)

round

Syntax:

VARNAME1 = round(VARNAME2)

Returns VARNAME2 rounded to the nearest whole number and assigns it to VARNAME1.

floor

Syntax:

VARNAME1(num) = floor(VARNAME2(num))
Returns VARNAME2 rounded down to the nearest whole number and assigns it to VARNAME1.

ceil

Syntax:

VARNAME1(num) = ceil(VARNAME2(num))

Returns VARNAME2 rounded up to the nearest whole number and assigns it to VARNAME1.

Math Expression Parsing

Syntax:

VARNAME1(num) = math(VARNAME2(str))

Assigns the result of evaluating the math expression VARNAME2 to VARNAME1. The expression can contain most standard math functions, operators, and parentheses. For example:

VARNAME1 = math("2 * (3 + 4)")

This would assign 14 to VARNAME1.