Numbers

Numbers in RuLA represent numeric values, including both integers and decimal numbers.

Creating Numbers

Write numbers directly without quotes:

42          # Integer
-7          # Negative number
3.14159     # Decimal number
0.5         # Decimal less than 1

Number Operations

Arithmetic

5 + 3           # Addition: 8
10 - 4          # Subtraction: 6
3 * 4           # Multiplication: 12
15 / 3          # Division: 5
17 // 5         # Integer division: 3
17 % 5          # Modulo (remainder): 2
2 ** 3          # Exponentiation: 8

Comparison

Rounding and Precision

Absolute Value and Sign

Useful Number Functions

Function
Description
Example

Sum of all numbers in a list

SUM([1, 2, 3]) β†’ 6

Average of numbers in a list

AVG([1, 2, 3]) β†’ 2

Smallest number in a list

MIN([3, 1, 2]) β†’ 1

Largest number in a list

MAX([3, 1, 2]) β†’ 3

Round to nearest integer

ROUND(2.5) β†’ 3

Round to N decimal places

ROUND(3.14159, 2) β†’ 3.14

Round down to integer

FLOOR(3.9) β†’ 3

Round up to integer

CEIL(3.1) β†’ 4

Absolute value

ABS(-5) β†’ 5

Sign of number (-1, 0, 1)

SIGN(-5) β†’ -1

Square root

SQRT(16) β†’ 4

Constrain to range

CLAMP(10, 0, 5) β†’ 5

Combinations (n choose k)

COMB(5, 2) β†’ 10

Sum of products

SUM_PRODUCT([1,2], [3,4]) β†’ 11

Working with Lists of Numbers

Aggregate functions work on lists:

Type Checking

To check if a value is a number:

Last updated

Was this helpful?