> For the complete documentation index, see [llms.txt](https://osl.mistium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://osl.mistium.com/legacy-osl-originos/precedence.md).

# Old Precedence Table

OSL evaluates expressions using a fixed operator precedence hierarchy. Operators with **higher precedence bind tighter** and are evaluated before lower-precedence operators. Operators at the same precedence level are evaluated **left-to-right**, unless otherwise stated.

All arithmetic operators share one precedence level. Mixing different arithmetic operators without parentheses produces a compiler warning because the result may differ from languages where multiplication and division bind more tightly than addition and subtraction.

Each binary operator consumes its left and right operands once while preserving that order.

Parentheses `(...)` may always be used to override precedence.

#### Precedence Table

<table data-header-hidden><thead><tr><th width="136.1881103515625"></th><th></th><th></th></tr></thead><tbody><tr><td>Level</td><td>Operators</td><td>Description</td></tr><tr><td>1</td><td><code>()</code></td><td>Grouping / explicit precedence override</td></tr><tr><td>2</td><td><code>+</code> <code>-</code> <code>/</code> <code>*</code> <code>^</code> <code>%</code> <code>??</code> <code>|></code></td><td>Operators</td></tr><tr><td>3</td><td><code>==</code> <code>!=</code> <code>&#x3C;</code> <code>></code> <code>&#x3C;=</code> <code>>=</code></td><td>Comparisons</td></tr><tr><td>4</td><td><code>bool ? val1 val2</code></td><td>Ternary operator</td></tr><tr><td>5</td><td><code>|</code> <code>&#x26;</code> <code>>></code> <code>&#x3C;&#x3C;</code> <code>^^</code></td><td>Bitwise operators</td></tr><tr><td>6</td><td>and, or, nor, nand, xor, xnor</td><td>Logical operators</td></tr><tr><td>7</td><td><a data-mention href="https://github.com/Mistium/OSL-Docs/tree/main/custom-syntax/inline.md">https://github.com/Mistium/OSL-Docs/tree/main/custom-syntax/inline.md</a></td><td>Lambda and inline functions</td></tr></tbody></table>

This table is in order of what gets evaluated first, within these groups its the left most operator that takes precedence.

```javascript
// Think of:
log 1 + 1 * 4

// As:
log (1 + 1) * 4
```

Because operators come first in the table, they are evaluated before comparisons and so you can do things like this:

```javascript
// this logs `false`
log 1 + 1 == 5 * 4

// the code above is functionally equivalent to
log (1 + 1) == (5 * 4)
```

Parenthesize mixed arithmetic even when the current left-to-right order is intentional:

```javascript
log (75 - 2) * 10
log 75 - (2 * 10)
```
