We do the AND operation, bit by bit, on the binary representation of 48, 27. Use the controls below to step through the bits. The corresponding truth table is shown below.
A | B | A & B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
You can change the operation by clicking/pressing on the operator.
We do the AND operation, bit by bit, on the binary representation of 48, 27. Use the controls below to step through the bits. The corresponding truth table is shown below.
A | B | A & B |
---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
I want to mention a point which might cause confusion while getting started with bitwise NOT operation.
In a bitwise NOT operation, all the leading zeros will be flipped to a 1. This means varying number of leading zeros produce different outputs from the same input.
Use the buttons below to add/remove leading zeros to see what outputs are produced. You can see the output value (40) changes even though the input value (23) doesn't.
The shift is done on binary representation of the first operand. The second operand is the number of positions to be shifted. The bits can be shifted to either left or right.
You can change the operation by pressing on the operator.
affect the output of the shift when the bits overflow.
Supports 6 to 12.
The 2 right-most digits are shifted off.
The vacant bits on the left side are filled with 0.
Usually, in most programming languages (including C/C++, Java, JavaScript and Python), only logical shifts are available.
Also note that in Python 3, the numbers are stored using arbitrary precision, which can be thought of infinite amount of zeros in front of the number.
The vacant bits on the left side are filled with the bits pushed off from the right side.
There is also a third type of bitwise shift: Arithmetic Shift. I have excluded it here, as it is analogus to logical shift when dealing with unsigned integers.