## Operators

The following table lists the precedence and associativity of all operators. Operators are listed top to bottom, in ascending precedence. Operators in the same cell have the same precedence. Operators are binary, unless the syntax is provided.

Operator | Description | `field` | `u8/u16` `u32/u64` | `bool` | Associativity |
---|---|---|---|---|---|

`**` | Power | ✓^{1} | Left | ||

`+x` `-x` `!x` | Positive Negative Negation | ✓ ✓ | ✓ ✓ ✓ | ✓ | Right |

`*` `/` `%` | Multiplication Division Remainder | ✓ ✓ | ✓ ✓ ✓ | | Left |

`+` `-` | Addition Subtraction | ✓ | ✓ | Left | |

`<<` `>>` | Left shift Right shift | ✓^{2} | Left | ||

`&` | Bitwise AND | ✓ | Left | ||

`|` | Bitwise OR | ✓ | Left | ||

`^` | Bitwise XOR | ✓ | Left | ||

`>=` `>` `<=` `<` | Greater or equal Greater Lower or equal Lower | ✓^{3} | ✓ | Left | |

`!=` `==` | Not Equal Equal | ✓ | ✓ | ✓ | Left |

`&&` | Boolean AND | ✓ | Left | ||

`||` | Boolean OR | ✓ | Left | ||

`c ? x : y` `if c { x } else { y }` | Conditional expression | ✓ | ✓ | ✓ | Right |

^{1}

The exponent must be a compile-time constant of type `u32`

^{2}

The right operand must be a compile time constant of type `u32`

^{3}

If neither of the operands can be determined to be a compile-time constant, then we have a restriction: for the check `a < b`

, if the field prime `p`

is represented on `N`

bits, `|a - b|`

must fit in `N - 2`

bits.
Failing to respect this condition will lead to a runtime error.