Version: 0.10.5

# Operations

## Table of Supported Operations​

OperationDescriptionRequirements
+Adds two private input types togetherTypes must be private input
-Subtracts two private input types togetherTypes must be private input
*Multiplies two private input types togetherTypes must be private input
/Divides two private input types togetherTypes must be private input
^XOR two private input types togetherTypes must be integer
&AND two private input types togetherTypes must be integer
|OR two private input types togetherTypes must be integer
<<Left shift an integer by another integer amountTypes must be integer
>>Right shift an integer by another integer amountTypes must be integer
!Bitwise not of a valueType must be integer or boolean
<returns a bool if one value is less than the otherUpper bound must have a known bit size
<=returns a bool if one value is less than or equal to the otherUpper bound must have a known bit size
>returns a bool if one value is more than the otherUpper bound must have a known bit size
>=returns a bool if one value is more than or equal to the otherUpper bound must have a known bit size
==returns a bool if one value is equal to the otherBoth types must not be constants
!=returns a bool if one value is not equal to the otherBoth types must not be constants

### Predicate Operators​

`<,<=, !=, == , >, >=` are known as predicate/comparison operations because they compare two values. This differs from the operations such as `+` where the operands are used in computation.

### Bitwise Operations Example​

``fn main(x : Field) {    let y = x as u32;    let z = y & y;}``

`z` is implicitly constrained to be the result of `y & y`. The `&` operand is used to denote bitwise `&`.

`x & x` would not compile as `x` is a `Field` and not an integer type.

### Logical Operators​

Noir has no support for the logical operators `||` and `&&`. This is because encoding the short-circuiting that these operators require can be inefficient for Noir's backend. Instead you can use the bitwise operators `|` and `&` which operate indentically for booleans, just without the short-circuiting.

``let my_val = 5;let mut flag = 1;if (my_val > 6) | (my_val == 0) {    flag = 0;}assert(flag == 1);if (my_val != 10) & (my_val < 50) {    flag = 0;}assert(flag == 0);``

### Shorthand operators​

Noir shorthand operators for most of the above operators, namely `+=, -=, *=, /=, %=, &=, |=, ^=, <<=`, and `>>=`. These allow for more concise syntax. For example:

``let mut i = 0;i = i + 1;``

could be written as:

``let mut i = 0;i += 1;``