A bit shift moves each digit in a set of bits left or right. The last bit in the direction of the shift is lost, and a 0 bit is inserted on the other end.
Bit shifts take number of times to shift as the right argument:
A single left shift multiplies a binary number by 2:
Two left shifts multiplies by 4. Three left shifts multiplies by 8.
And similarly, shifting right divides by 2, throwing out any remainders.
Pass Your Interviews with My FREE 7-Day Crash Course
I'll teach you the right way of thinking for breaking down tricky algorithmic coding interview questions you've never seen before.
No prior computer science training necessary—I'll get you up to speed quickly, skipping all the overly academic stuff.
No spam. One-click unsubscribe if you hate it.