Operators
Order of operations
TrueMath evaluates an expression in this order, from highest precedence to lowest:- Exponentiation (
^) - Negation (
-x) - Multiplication and division (
*,/) - Addition and subtraction (
+,-) - Comparison (
>,<,>=,<=,==,!=) - Logical (
&&,\|\|,!) - Assignment (
=) — the lowest precedence, so the entire right-hand side is evaluated before it is assigned (x = a + b * ccomputesa + b * c, then assigns).
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.
-2^2 is -(2^2) = -4. Use
parentheses whenever the intended grouping isn’t obvious — TrueMath evaluates
(a + b) / c exactly as written.
Boolean results
Comparison and logical operators produce1 (true) or 0 (false), and a condition
expects a boolean — true/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.
