Interactive Binary Playground
128
0
2⁷
Click to toggle!
64
0
2⁶
Click to toggle!
32
0
2⁵
Click to toggle!
16
1
2⁴
Click to toggle!
8
0
2³
Click to toggle!
4
1
2²
Click to toggle!
2
1
2¹
Click to toggle!
1
0
2⁰
Click to toggle!
Shift Explanation
No operations yet. Try shifting!
⚠️ Overflow Detected!
The leftmost bit (1) was lost during the shift. This means:
- Expected result:
- Actual result:
- Lost value:
⚠️ Underflow Detected!
The rightmost bit (1) was lost during the shift. This means:
- Expected result:
- Actual result:
- Lost value:
🏆 Binary Shift Challenges
Loading challenge…
📚 Master Binary Shifts
🔄 Binary Shift Left
When you shift left:
- All bits move one position to the left
- A 0 is added on the right
- The leftmost bit falls off (potential overflow!)
- The number is multiplied by 2
00101100 → 01011000
44 × 2 = 88
➡️ Binary Shift Right
When you shift right:
- All bits move one position to the right
- A 0 is added on the left
- The rightmost bit is lost
- The number is divided by 2 (integer division)
00101101 → 00010110
45 ÷ 2 = 22 (remainder lost)
⚠️ Understanding Overflow
Overflow occurs when shifting causes data loss:
- Left shift overflow: When the leftmost bit is 1 and gets shifted out
- Example: 10000001 (129) shifted left loses the '1', giving 00000010 (2) instead of 258
- Prevention: Check if the leftmost bit is 1 before shifting left
🎯 Quick Practice
Try these examples in the playground:
- Shift 00001000 left three times. What do you get?
- Start with 10000000 and shift left. What happens?
- Take 11111111 and shift right twice. What's the result?