Try it
Before
After (≪ 2, gold = dropped / new)
Understand the result
What's going on
Every binary digit is worth twice the one to its right. Slide the whole pattern one place left and every bit is suddenly worth double what it was - the value doubles. Slide it right and every bit is worth half - the value halves. A bit shift is multiplication or division by two, done by moving digits instead of doing arithmetic.
The formula
value ≪ n = value × 2ⁿ
value ≫ n = value ÷ 2ⁿ (rounded down)
Show the derivation, mnemonic, and worked example
Build it up
Shifting left by one is the same move as writing a decimal number and adding a zero on the end - ×10 in decimal becomes ×2 in binary. Shifting right drops the last digit, which is the binary equivalent of integer-dividing by 10 in decimal. Shift by more than one place and you’re just repeating the move - shift left by 3 is ×2×2×2, or ×8.
Worked example
Worked example
5 in 8-bit binary: 00000101
Shift left by 2: 00010100
= 20 (5 × 2² = 5 × 4)





