Skip to main content

Number

Number can either be an integer (whole number) or a decimal number (floating point). It can be defined using digits 0-9, . (decimals separator) and _ for readability.

All examples below are valid:

100;
1_000_000;
1.54;
info

Internally, numbers are represented using double-precision floating-points.

Operators

Unary operators

OperatorDescriptionExample
-Negation-a

Arithmetic operators

All arithmetic operators follow the natural mathematical precedence. E.g. (a + b) * c is not the same as a + b * c.

OperatorDescriptionExample
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
^Exponentiationa ^ b
%Modulusa % b

Comparison operators

OperatorDescriptionExample
==Equalitya == b
!=Inequalitya != b
<Less thana < b
>Greater thana > b
<=Less than or equala <= b
>=Greater than or equala >= b

Functions

abs

Accepts a number, and returns the absolute value.

Syntax

abs(-1.23); // 1.23
abs(10); // 10

rand

Accepts a positive number (limit), and returns a generated number between 1 and provided limit.

Syntax

rand(100); // random whole number between 1 and 100, both included
rand(2); // random number, 1 or 2

floor

Accepts a number and rounds it down. It returns the largest integer less than or equal to given number.

Syntax

floor(5.1); // 5
floor(5.9); // 5

round

Accepts a number and rounds the number to the nearest integer.

Syntax

round(5.1); // 5
round(5.9); // 6

ceil

Accepts a number and rounds it up. It returns the smallest integer greater than or equal to given number.

Syntax

ceil(5.1); // 6
ceil(5.9); // 6

number

Accepts one argument, tries to convert number or string to number, throws an error on failure

number('20'); // 20
number(20); // 20

Note: In decision tables it is suggested to combine number with isNumeric so that expression can be protected from failing resulting in row being skipped. For example isNumeric($) && number($).

isNumeric

Accepts one argument, returns bool, true if variable is number or string that can be converted to a number

isNumeric('20'); // true
isNumeric('test'); // false