🎮 Binary Shift Master

OCR Computer Science J277 - Mr Brown

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 Click to toggle!
4 1 Click to toggle!
2 1 Click to toggle!
1 0 2⁰ Click to toggle!

Binary

00010110

Decimal

22

Hexadecimal

16

Shift Explanation

No operations yet. Try shifting!

🏆 Binary Shift Challenges

Challenges Complete

0

Total Points

0

Loading challenge…

🏅 Achievements

📚 Master Binary Shifts

🔄 Binary Shift Left

When you shift left:

  1. All bits move one position to the left
  2. A 0 is added on the right
  3. The leftmost bit falls off (potential overflow!)
  4. The number is multiplied by 2
00101100 → 01011000
44 × 2 = 88

➡️ Binary Shift Right

When you shift right:

  1. All bits move one position to the right
  2. A 0 is added on the left
  3. The rightmost bit is lost
  4. 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?