Learn
1.1.5 | BINARY SHIFTS
01 | MOVE THE BITS, KEEP THE REGISTER WIDTH
A binary shift moves bits to different place-value positions. Moving left places them in larger-value columns; moving right places them in smaller-value columns.
This lesson uses logical shifts of unsigned 8-bit values. The register keeps eight positions. Zeros enter the newly empty positions, and bits moved beyond the edge are discarded.
The bits do not rotate around to the other end. Signed arithmetic shifts follow different rules and are outside this lesson’s model.
02 | LEFT SHIFT BY ONE POSITION
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| Move left | ← 1 position | |||||||
| After | 0 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
Discarded: 0. Inserted: 1 zero. Green cells show the inserted zeros.
Start with 00001101, representing 13. Every bit moves one column left, so the rightmost position receives a 0.
00001101₂ = 13₁₀ 00011010₂ = 26₁₀ 13 × 2 = 26
The discarded leftmost bit is 0, so no significant value is lost. Each retained 1 moves to a place worth twice as much.
03 | LEFT SHIFT BY SEVERAL POSITIONS
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| Move left | ← 2 positions | |||||||
| After | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 |
Discarded: 00. Inserted: 2 zeros. Green cells show the inserted zeros.
Two left shifts multiply by 2 twice: ×4. Three multiply by 8. In general, a left shift of n positions multiplies by 2ⁿ, provided no significant 1 bits are lost.
13 × 2² = 13 × 4 = 52 00001101 → 00110100
“Left two” means multiply by four when it fits, not add two or multiply by two.
04 | RIGHT SHIFT BY ONE POSITION
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 |
| Move right | → 1 position | |||||||
| After | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 |
Discarded: 0. Inserted: 1 zero. Green cells show the inserted zeros.
Every bit moves one column right. A 0 enters on the left and the old rightmost bit is discarded.
00101100₂ = 44₁₀ 00010110₂ = 22₁₀ 44 ÷ 2 = 22
Here the discarded bit is 0, so the division gives an exact whole-number result.
05 | RIGHT SHIFTS DISCARD FRACTIONAL PARTS
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| Move right | → 1 position | |||||||
| After | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
Discarded: 1. Inserted: 1 zero. Green cells show the inserted zeros.
13 ÷ 2 = 6.5, but an unsigned integer register does not retain the .5. The low bit representing the remainder is discarded, leaving 6.
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 1 |
| Move right | → 2 positions | |||||||
| After | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
Discarded: 11. Inserted: 2 zeros. Green cells show the inserted zeros.
43 ÷ 4 = 10.75. The two low bits 11 are lost and the retained result is 10. For this unsigned model, a right shift of n positions gives integer division by 2ⁿ, discarding any fractional part.
06 | LEFT SHIFTS CAN LOSE IMPORTANT BITS
| Row | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Before | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 |
| Move left | ← 1 position | |||||||
| After | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Discarded: 1. Inserted: 1 zero. Green cells show the inserted zeros.
The leftmost 1 is discarded. The correct mathematical product is 193 × 2 = 386, which cannot fit in an unsigned 8-bit value.
Full product: 386₁₀ = 110000010₂ (9 bits) Retained bits: 10000010₂ = 130₁₀
Do not say that this shift correctly multiplies the retained value by two. It attempted that effect, but the fixed-width result lost a significant bit.
For an unsigned 8-bit value, a one-position left shift fits exactly only when the original value is at most 127. For two positions the maximum is 63.
07 | LOST ZEROS AND LOST ONES ARE DIFFERENT
Every shift can discard edge bits. Losing a leading zero on a left shift does not change the expected product; losing a leading 1 does.
A right shift can discard remainder information. If you shift back afterwards, you may not recover the original pattern.
13: 00001101 Right 1 → 00000110 (6) Left 1 → 00001100 (12), not 13
The lost bit is not stored somewhere inside the result waiting to be restored. Explain what leaves the register and where the new zeros enter.
08 | TRY IT: SHIFT AN EIGHT-BIT PATTERN
Predict the result, then check it. The diagram keeps the original and shifted bytes horizontal and highlights inserted zeros.
09 | ANSWER WITH THE PATTERN AND THE REASON
- Identify direction and number of positions.
- Move the bits, preserving the eight-bit width.
- Insert zeros at the correct edge.
- Record bits discarded at the other edge.
- State the retained binary and denary values.
- Explain multiplication, integer division or lost significant bits.
Keep your place values aligned. Never simply add zeros to make a nine- or ten-bit answer when the question specifies an 8-bit register.
PRACTISE | SHIFT WITHOUT THE CHECKER
Complete the activities, then use the Questions tab for independent practice.