•Perform logical, arithmetic and circular shifts on binary data
•Perform bitwise operations AND, OR and XOR
•Use masks to manipulate bits
A logical shift to the right will cause the Least Significant Bit (LSB) to be moved into the carry bit.
The Most Significant Bit (MSB) will then be padded out with a 0.
0 | 1 | 0 | 0 | 1 | 1 | 1 | 1 |
---|
0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 |
---|
Before
Carry bit
After
1 |
---|
Carry bit
Shift right 1 place:
What is the result after shifting 2 more places?
0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
---|
1
A logical shift to the left will cause the Most Significant Bit (MSB) to be moved into the carry bit.
A zero will be carried into the LSB.
0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 |
---|
1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 |
---|
Before
Carry bit
After
0 |
---|
Carry bit
Shift left 1 place:
An arithmetic shift can be used to multiple or divide a binary number, for example:
If you were to apply a 1 place left shift, this has the same effect as multiplying by 2.
0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
---|
= 22
Shifted one place to the left becomes:
0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |
---|
= 44
What would happen if you were to shift 2 places to the left instead of 1?
Multiply 17 by 1 | 00010001 |
Multiply 17 by 4 with 2 left shifts | 01000100 |
Add together the results | 01010101 |
= 85
Note that if you divide an odd number by 2, it is rounded down
What is the denary value before and after an arithmetic shift right one place?
If you shift right one place and then left one place, you don’t always end up with the value you started with!
Complete the questions in Task 1 on your worksheets.
also called XOR
Have a go at Task 2 on your worksheet