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.
You can change the operation by pressing on the operator.
The right-most digit is shifted off.
The vacant bit on the left side is filled with 0.
Usually, in most programming languages (including C/C++, Java, JavaScript and Python), only Logical Shifts are available.
The vacant bit on the left side is filled with the bit 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.