Operators and Precedence
TX1 follows standard mathematical precedence. Parentheses override everything.
Full Precedence Table (high → low)
| Precedence | Operators | Associativity | Examples | |||||
|---|---|---|---|---|---|---|---|---|
| 7 | ^ | right | 2^3^2 = 2^(3^2) = 512 | |||||
| 6 | *, /, % | left | 10 / 2 * 5 = 25 | |||||
| 5 | +, -, unary - | left | 5 + 3 - 2 | |||||
| 4 | <, <=, >, >= | left | 5 > 3 → 1 | |||||
| 3 | =, ==, <>, != | left | 5 = 5 → 1 | |||||
| 2 | &, && (logical AND) | left, short-circuit | A && B | |||||
| 1 | `\ | , \ | \ | ` (logical OR) | left, short-circuit | `A \ | \ | B` |
Arithmetic
| Operator | Meaning |
|---|---|
+ | Addition |
- | Subtraction / unary negation |
* | Multiplication |
/ | Division (zero-guarded; division by zero → #DIV/0) |
% | Modulo |
^ | Exponentiation |
Comparison
Comparison operators return 1 (true) or 0 (false).
= IF(L5 > 1000, "over", "under")
Equality
=and==are identical.=is classical spreadsheet;==is programmer-familiar.<>and!=are identical.
Logical (Short-Circuit)
&&only evaluates the right operand if the left is truthy.||only evaluates the right operand if the left is falsy.
Use this to guard division:
= IF(L2 <> 0 && L1/L2 > 2, L1, 0)
If L2 is zero, the right side never runs, so no #DIV/0.
Unary Minus
= -L5 → negate line 5
= -#rate → negate a variable
Parenthesis
Always works, and always readable:
= (L1 + L2) * (L3 - L4)
Boolean Results
1 is true, 0 is false. Comparisons produce 1 or 0 which can be multiplied:
= (L5 > 1000) * L5 * 0.9 // 10% discount ONLY above $1,000
This is an idiomatic spreadsheet pattern you'll see often in TX1 formulas.