> ## Documentation Index
> Fetch the complete documentation index at: https://docs.truemath.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Operators and precedence

> TrueMath's arithmetic, comparison, logical, and assignment operators, and the order of operations used to evaluate them.

TrueMath equations use the following operators. See [Writing equations](/authoring/writing-equations) for the surrounding grammar.

## Operators

| Category   | Operators                   | Notes                                             |
| ---------- | --------------------------- | ------------------------------------------------- |
| Arithmetic | `+` `-` `*` `/` `^`         | `^` is exponentiation; `1 / x` is the reciprocal. |
| Comparison | `==` `!=` `<` `>` `<=` `>=` | Return `1` (true) or `0` (false).                 |
| Logical    | `&&` `\|\|` `!`             | AND, OR, NOT.                                     |
| Assignment | `=`                         | Binds a value to a variable.                      |
| Grouping   | `( )`                       | Overrides the order of operations.                |

## 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`](/math/functions/arithmetic-and-powers) or [`pmt`](/math/functions/finance) aren't operators: a function call evaluates its arguments and resolves to a single value before any surrounding operator applies.

```
3 + 4 * 5      => 23
(3 + 4) * 5    => 35
-2^2           => -4
```

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.

<Warning>
  `=` is **assignment**; `==` is **comparison**. Use `==` inside conditions:
  `if(term == 30; rate_30yr; rate_15yr)`. See
  [Conditionals and logic](/math/functions/conditionals-and-logic).
</Warning>

## Boolean results

Comparison and logical operators produce `1` (true) or `0` (false), and a condition
expects a [boolean](/math/types/scalar-numbers#booleans) — `true`/`false` or `1`/`0`.
The condition must be a scalar. See [Booleans](/math/types/scalar-numbers#booleans) for
how `true`/`false` relate to `1`/`0` and how other values are evaluated.
