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;
Operators
Unary operators
Operator | Description | Example |
---|---|---|
- | 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
.
Operator | Description | Example |
---|---|---|
- | Addition | a + b |
- | Subtraction | a - b |
* | Multiplication | a * b |
/ | Division | a / b |
^ | Exponentiation | a ^ b |
% | Modulus | a % b |
Comparison operators
Operator | Description | Example |
---|---|---|
== | Equality | a == b |
!= | Inequality | a != b |
{'<'} | Less than | a < b |
> | Greater than | a > b |
{'<='} | Less than or equal | {'a <= b'} |
> = | Greater than or equal | a >= 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
Updated 16 days ago