Operators
Solidity supports the following types of operators.
- Arithmetic Operators
- Comparison Operators
- Logical (or Relational) Operators
- Assignment Operators
- Conditional (or ternary) Operators
Arithmetic operators
Solidity supports the following arithmetic operators
| + (Addition) |
| - (Subtraction) |
| * (Multiplication) |
| / (Division) |
| % (Modulus) |
| ++ (Increment) |
| -- (Decrement) |
Comparison Operators
Solidity supports the following comparison operators
| = = (Equal) |
| != (Not Equal) |
| > (Greater than) |
| < (Less than) |
| >= (Greater than or Equal to) |
| <= (Less than or Equal to) |
Logical Operators
Solidity supports the following logical operators
| && (Logical AND) |
| || (Logical OR) |
| ! (Logical NOT) |
Bitwise Operators
Solidity supports the following bitwise operators
| & (Bitwise AND) |
| | (BitWise OR) |
| ^ (Bitwise XOR) |
| ~ (Bitwise Not) |
| << (Left Shift) |
| >> (Right Shift) |
| >>> (Right shift with Zero) |
Assignment Operators
Solidity supports the following assignment operators
| = (Simple Assignment ) |
| += (Add and Assignment) |
| −= (Subtract and Assignment) |
| *= (Multiply and Assignment) |
| /= (Divide and Assignment) |
| %= (Modules and Assignment) |
Conditional Operator (? :)
The conditional operator first evaluates an expression for a true or false value and then executes one of the two given statements depending upon the result of the evaluation.
| ? : (Conditional ) |