Functions Reference
Built-in math, rounding, and trigonometric functions.
The formula engine includes a comprehensive set of built-in functions for mathematical operations.
Math Functions
abs(x) Absolute value abs(-5) = 5
ceil(x) Round up ceil(4.2) = 5
ceiling(x) Round up (alias) ceiling(4.2) = 5
floor(x) Round down floor(4.8) = 4
round(x) Round nearest round(4.5) = 5
round(x; n) Round to n decimals round(3.456; 2) = 3.46
truncate(x; n) Truncate to n places truncate(3.456; 2) = 3.45
min(a; b; ...) Minimum min(3; 1; 4) = 1
max(a; b; ...) Maximum max(3; 1; 4) = 4
sqrt(x) Square root sqrt(16) = 4
pow(x; n) Power pow(2; 3) = 8
log(x) Natural logarithm log(e) = 1
log10(x) Base-10 logarithm log10(100) = 2
exp(x) Exponential exp(1) = 2.718...
Logical:
and(a; b) Logical AND and(1; 1) = 1
or(a; b) Logical OR or(0; 1) = 1
Text:
len(text) String length len("hello") = 5
text(value) Number to text text(42) = "42"
number(text) Text to number number("42") = 42
concat(a; b; ...) Concatenate strings concat("hi"; " "; "there") = "hi there"
join(sep; a; ...) Join with separator join("-"; "a"; "b"; "c") = "a-b-c"Trigonometric Functions
All trigonometric functions work in radians. To convert degrees to radians, multiply by π/180.
sin(x) Sine (radians) sin(0) = 0 cos(x) Cosine cos(0) = 1 tan(x) Tangent tan(0) = 0 asin(x) Arc sine asin(1) = π/2 acos(x) Arc cosine acos(1) = 0 atan(x) Arc tangent atan(1) = π/4
Rounding Functions
- ceil(x) / ceiling(x) — always rounds up: ceil(4.1) = 5. Use for quantities that must be whole.
- floor(x) — always rounds down: floor(4.9) = 4.
- round(x) — rounds to nearest integer: round(4.5) = 5.
- round(x; n) — rounds to n decimal places: round(3.14159; 2) = 3.14.
- truncate(x; n) — truncates to n decimal places (no rounding): truncate(3.14159; 2) = 3.14.
Logarithmic Functions
- log(x) — natural logarithm (base e): log(e) = 1.
- log10(x) — base-10 logarithm: log10(100) = 2.
Logical Functions
- and(a; b) — logical AND: returns 1 when both arguments are truthy, 0 otherwise.
- or(a; b) — logical OR: returns 1 when either argument is truthy, 0 otherwise.
Text Functions
- len(text) — returns the length of a string: len("hello") = 5.
- text(value) — converts a number to text: text(42) = "42".
- number(text) — converts text to a number: number("42") = 42.
- concat(a; b; ...) — concatenates strings: concat("width: "; text($width)) = "width: 1000".
- join(separator; val1; val2; ...) — joins values with a separator: join("; "; "a"; "b"; "c") = "a; b; c".
Use ceil() for material quantities — you can't buy half a panel, so always round up.