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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.ton.org/feedback

```json
{
  "path": "/tolk/syntax/operators",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Operators

Tolk provides standard operators for integers and booleans.

## Operator priority

From highest to lowest.

### Parenthesis `(` `)`

Groups expressions: `(1 + 2) * 3`; or creates [tensors](/languages/tolk/types/tensors): `pair = (1, 2)`.

### Square brackets `[` `]`

A universal constructor `[1, 2]` creates an array, `lisp_list`, or shaped tuple. See [tuples](/languages/tolk/types/tuples).

### Operator `lazy`

With [lazy loading](/languages/tolk/features/lazy-loading) the compiler loads only the accessed fields and skips the rest.

### Non-null assertion operator `!`

Skips the [nullability](/languages/tolk/types/nullable) check: `someVar!`.

### Unary operators `!` `~` `-` `+`

[Logical negation](/languages/tolk/types/booleans) `!x`, bitwise not `~x`, unary `-x` and `+x`.

### Operators `as` `is` `!is`

[Unsafe `as` cast](/languages/tolk/types/type-checks-and-casts) and checks for [union types](/languages/tolk/types/unions): `someVar is int`.

### Multiplicative `*` `/` `%` `^/` `~/`

Integer multiplication, division, modulo, ceiling-division, and rounding-division. All [integers](/languages/tolk/types/numbers) have 257-bit precision.

### Additive `+` `-`

Standard integer addition and subtraction.

### Shifts `<<` `>>` `^>>` `~>>`

Bitwise shifts, extended by ceiling-right and rounding-right.

### Comparison `==` `<` `>` `<=` `>=` `!=` `<=>`

Comparison operators. `<=>` is known as the spaceship or sign operator. Operators `==` and `!=` also work for several non-numeric types. For example, [addresses](/languages/tolk/types/address).

### Bitwise `&` `|` `^`

Standard bitwise operators, applicable to both integers and booleans.

### Logical `&&` `||`

[Short-circuit](/languages/tolk/types/booleans#logical-vs-bitwise-operators): the right operand is evaluated only when necessary.

### Assignment `=` `+=` `-=` and other

Assignment and augmented assignments.

### Null-coalescing `??`

Returns the left operand if it is not `null`; otherwise, evaluates and returns the right operand. See [nullable types](/languages/tolk/types/nullable#null-coalescing-operator).

### Ternary `... ? ... : ...`

Ternary expressions are available in [conditions](/languages/tolk/syntax/conditions-loops).

## Missing operators

Tolk does not support `i++` and `i--`. Use `i += 1` and `i -= 1` instead.

## Warnings on unexpected precedence

A common pitfall:

```tolk theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
if (flags & 0xFF != 0) {
    // ...
}
```

This does not check the lowest byte. It is parsed as `flags & (0xFF != 0)`, because `!= ` has higher precedence, as in C++.

To prevent such cases, the compiler reports an error:

```ansi theme={"theme":{"light":"github-light-default","dark":"dark-plus"},"languages":{"custom":["/resources/grammars/tolk.tmLanguage.json","/resources/grammars/tlb.tmLanguage.json","/resources/grammars/fift.tmLanguage.json","/resources/grammars/tasm.tmLanguage.json","/resources/grammars/func.tmLanguage.json"]}}
error: & has lower precedence than !=, probably this code won't work as you expected.
       Use parenthesis: either (... & ...) to evaluate it first, or (... != ...) to suppress this error.

   2 |     if (flags & 0xFF != 0) {
     |         ^^^^^^^^^^^^^^^^^
```
