Numbers & Text > Math


Arithmetic

Add / Subtract / Multiply / Divide

arithmetic-block

Adds/Subtracts/Multiplies/Divides the two provided numbers. Note that only Chuck Norris can divide by 0.

([NUMBER] + [NUMBER])
([NUMBER] - [NUMBER])
([NUMBER] * [NUMBER])
([NUMBER] / [NUMBER])

Negate

negate-block

Flips the sign of the given number.

-([NUMBER])

Remainder (Modulo)

remainder-block

Returns the integer remainder after dividing the first number by the second.

([NUMBER] % [NUMBER])

Random Numbers

Random Integer

random-int-block

Returns a random integer between the first and second numbers, inclusive. Provide integers for both numbers.

randomInt(Math.floor(Number), Math.floor(Number))

Random Floating Point Number

random-float-block

Returns a random floating point number between 0 and 1, inclusive.

randomFloat()

Increment / Decrement

Increment / Decrement Number

increment-decrement-block

Adds (or subtracts) the given number to/from a number attribute.

[ATTRIBUTE] += [NUMBER];
[ATTRIBUTE] -= [NUMBER];

Operations

Absolute Value

abs-block

Returns the absolute value of the given number. (If it is negative, makes it positive.)

Math.abs([NUMBER])

Smaller / Larger of Two Numbers

smaller-block larger-block

Returns the smaller (or larger) of the two numbers.

Math.min([NUMBER], [NUMBER])
Math.max([NUMBER], [NUMBER])

Round / Floor / Ceiling

round-block

Returns the nunber as an integer, with rounding applied as follows:

Round - Rounds up if the fractional part is 0.5 or more. Otherwise, rounds down.

Floor - Always rounds down.

Ceiling - Always rounds up.

Math.round([NUMBER])
Math.floor([NUMBER])
Math.ceil([NUMBER])

Conversion

Number Conversion

number-convert-block

Converts the given value (can be any type) to a number. In practice, this is mainly useful for text and booleans (where true = 1, false = 0).

asNumber([VALUE])