A Singapore Government Agency Website

Number

Number can be either a whole number (integer) or a decimal (floating-point). It is composed using digits (0–9), a period (.) as the decimal point, and underscores (_) for improved readability.

The following examples are all valid:

100;
1_000_000;
1.68;

Operators


  • Negation: -a
  • Addition: a + b
  • Subtraction: a - b
  • Multiplication: a * b
  • Division: a / b
  • Exponentiation: a ^ b
  • Modulus: a % b
  • Equality: a == b
  • Inequality: a != b
  • Less than: a < b
  • More than: a > b
  • Less than or equal: a <= b
  • Greater than or equal: a >= b

Functions


abs

Returns the absolute (non-negative) value of the given number.

abs(-1.68); // 1.68
abs(10);    // 10

rand

Generates a random number between 1 and the specified positive limit.

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

floor

Rounds a number down to the nearest whole number that is less than or equal to the input.

floor(4.1); // 4
floor(4.9); // 4

round

Rounds a number to the closest value. Optionally accepts a second argument to specify the number of decimal places.

round(4.1);     // 4
round(4.9);     // 5
round(4.156, 2); // 4.16

ceil

Rounds a number up to the nearest whole number that is greater than or equal to the input.

ceil(4.1); // 5
ceil(4.9); // 5

trunc

Truncates a number by removing the decimal portion without rounding.

trunc(4.9);  // 4
trunc(-4.9); // -4

number

Convert the input (number or numeric string) into a number; throws an error if the conversion fails.

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

Tip: When working with decision tables, it’s recommended to use isNumeric alongside number to prevent expression errors that could cause a row to be ignored. For example: isNumeric($) and number($).

isNumeric

Checks if the input is a number or a string that can be converted into a number, and returns true or false accordingly.

isNumeric('20');    // true
isNumeric('hello'); // false
Chat with me!
Bot Launcher