Operations in the Arithmetic Expressions
Learn about the operations we can perform in the arithmetic expression, the priority of operations, and choosing a numeral system.
We'll cover the following...
The operations in arithmetic expression
The following table shows the operations we can perform in arithmetic expressions.
Operation | Description | Example |
---|---|---|
Calculations | ||
* |
Multiplication | echo "$((2 * 9)) = 18" |
/ |
Division | echo "$((25 / 5)) = 5" |
% |
The remainder of division | echo "$((8 % 3)) = 2" |
+ |
Addition | echo "$((7 + 3)) = 10" |
- |
Subtraction | echo "$((8 - 5)) = 3" |
** |
Exponentiation | echo "$((4**3)) = 64" |
Bitwise operations | ||
~ |
Bitwise NOT | echo "$((~5)) = -6" |
<< |
Bitwise left shift | echo "$((5 << 1)) = 10" |
>> |
Bitwise right shift | echo "$((5 >> 1)) = 2" |
& |
Bitwise AND | echo "$((5 & 4)) = 4" |
| |
Bitwise OR | echo "$((5 | 2)) = 7" |
^ |
Bitwise XOR | echo "$((5 ^ 4)) = 1" |
Assignments | ||
= |