# Operations

## Table of Supported Operations

OperationDescriptionRequirements
+Adds two concealed types togetherTypes must be concealed
-Subtracts two concealed types togetherTypes must be concealed
*Multiplies two concealed types togetherTypes must be concealed
/Divides two concealed types togetherTypes must be concealed
^XOR two concealed types togetherTypes must be integer
&AND two concealed 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;
}
constrain flag == 1;

if (my_val != 10) & (my_val < 50) {
flag = 0;
}
constrain flag == 0;