Skip to main content

Numbers

FunctionDescriptionMeta
abs

y := abs(x)

Returns the number without its sign.

Arguments:
x (number)

the number to take the absolute value of

Returns:
y (number)

the absolute value of x

Wasm
ceil

y := ceil(x)

Rounds the number up to the nearest integer.

Arguments:
x (number)

the number to round

Returns:
y (number)

the result of rounding x up

v0.26.0 Wasm
x / y

x / y

Divides the first number by the second number.

Arguments:
x (number)

the dividend

y (number)

the divisor

Returns:
z (number)

the result of x divided by y

Wasm
floor

y := floor(x)

Rounds the number down to the nearest integer.

Arguments:
x (number)

the number to round

Returns:
y (number)

the result of rounding x down

v0.26.0 Wasm
x - y

x - y

Minus subtracts the second number from the first number or computes the difference between two sets.

Arguments:
x (any<number, set[any]>)
y (any<number, set[any]>)
Returns:
z (any<number, set[any]>)

the difference of x and y

Wasm
x * y

x * y

Multiplies two numbers.

Arguments:
x (number)
y (number)
Returns:
z (number)

the product of x and y

Wasm
numbers.range

range := numbers.range(a, b)

Returns an array of numbers in the given (inclusive) range. If a==b, then range == [a]; if a > b, then range is in descending order.

Arguments:
a (number)

the start of the range

b (number)

the end of the range (inclusive)

Returns:
range (array[number])

the range between a and b

v0.22.0 Wasm
numbers.range_step

range := numbers.range_step(a, b, step)

Returns an array of numbers in the given (inclusive) range incremented by a positive step. If "a==b", then "range == [a]"; if "a > b", then "range" is in descending order. If the provided "step" is less then 1, an error will be thrown. If "b" is not in the range of the provided "step", "b" won't be included in the result.

Arguments:
a (number)

the start of the range

b (number)

the end of the range (inclusive)

step (number)

the step between numbers in the range

Returns:
range (array[number])

the range between a and b in step increments

v0.56.0 SDK-dependent
x + y

x + y

Plus adds two numbers together.

Arguments:
x (number)
y (number)
Returns:
z (number)

the sum of x and y

Wasm
rand.intn

y := rand.intn(str, n)

Returns a random integer between 0 and n (n exclusive). If n is 0, then y is always 0. For any given argument pair (str, n), the output will be consistent throughout a query evaluation.

Arguments:
str (string)

seed string for the random number

n (number)

upper bound of the random number (exclusive)

Returns:
y (number)

random integer in the range [0, abs(n))

v0.31.0 SDK-dependent
x % y

x % y

Returns the remainder for of x divided by y, for y != 0.

Arguments:
x (number)
y (number)
Returns:
z (number)

the remainder

Wasm
round

y := round(x)

Rounds the number to the nearest integer.

Arguments:
x (number)

the number to round

Returns:
y (number)

the result of rounding x

Wasm