Skip to main content
TrueMath equations use the following operators. See Writing equations for the surrounding grammar.

Operators

Order of operations

TrueMath evaluates an expression in this order, from highest precedence to lowest:
  1. Exponentiation (^)
  2. Negation (-x)
  3. Multiplication and division (*, /)
  4. Addition and subtraction (+, -)
  5. Comparison (>, <, >=, <=, ==, !=)
  6. Logical (&&, \|\|, !)
  7. Assignment (=) — the lowest precedence, so the entire right-hand side is evaluated before it is assigned (x = a + b * c computes a + b * c, then assigns).
Functions like sqrt or pmt aren’t operators: a function call evaluates its arguments and resolves to a single value before any surrounding operator applies.

Operators and units

Every operator works on unit numbers as readily as on plain numbers. Comparison converts compatible units before comparing, so a value in metres and the same value in centimetres are equal; comparing across dimensions is rejected rather than answered:
3m < 5kg returns input.incompatible_units — there is no true or false for it. Arithmetic follows the same rules, deriving a dimension where one applies: see Conversion behavior and Combining types.
Because the exponent binds tighter than the leading minus, -2^2 is -(2^2) = -4. Use parentheses whenever the intended grouping isn’t obvious — TrueMath evaluates (a + b) / c exactly as written.
= is assignment; == is comparison. Use == inside conditions: if(term == 30; rate_30yr; rate_15yr). See Conditionals and logic.

Boolean results

Comparison and logical operators produce 1 (true) or 0 (false), and a condition expects a booleantrue/false or 1/0. The condition must be a scalar. See Booleans for how true/false relate to 1/0 and how other values are evaluated.