3.3.4 - Logical binary shifts
Move bits left or right in an eight-bit pattern, then relate logical shifts to multiplication and whole-number division by powers of two. Learn when losing a bit changes the arithmetic result.
Moving bits and inserting zeros
A logical shift moves every bit a stated number of positions and fills each empty position with zero.
For a left shift, bits move towards the higher place values. Start with 00101100 and shift left once. The leftmost 0 leaves the eight-bit field, each remaining bit moves left, and a 0 enters at the right. The result is 01011000. A second left shift gives 10110000.
For a right shift, bits move towards lower place values. A right shift of 00101100 gives 00010110: the rightmost 0 leaves, and a 0 enters at the left. A second right shift gives 00001011.
| Operation on 00101100 | Result |
|---|---|
| Left by one | 01011000 |
| Left by two | 10110000 |
| Right by one | 00010110 |
| Right by two | 00001011 |
Keep the field eight bits wide. A discarded bit does not reappear at the other end; that would be a rotation. A logical right shift inserts zeros even if the old leftmost bit was 1. This course uses unsigned whole numbers, logical shifts and at most eight bits; you do not need fractional or signed-number representations here.
Multiplication and division by powers of two
Moving a 1 bit one place left doubles its contribution because each binary place value is twice the value to its right.
Continue this lesson.
You’re previewing NovaLearn without an account. Create a free account to read the rest.
Create free account