I wrote this tool after losing too much time mentally visualizing bit shifts during a NIC driver debugging session. Drop in a value, pick a shift operation, and see exactly what happens to every bit in the 32-bit word.
Enter a value and shift amount, then select an operation — results update instantly with bit visualization.
<<) and signed right shift (>>) operators preserve sign behavior. Unsigned right shift (>>>) fills with zeros from the left. Shift amounts above 31 wrap modulo 32 (JavaScript uses only the lower 5 bits: shift & 0x1F).
A bit shift is an operation that moves the individual bits of a binary number left or right by a specified number of positions. It's one of the fastest operations a CPU can perform — often just a single clock cycle — which makes it invaluable in performance-critical systems programming, graphics rendering, cryptography, and embedded firmware. I reach for bit shifts constantly when packing and unpacking data in network protocols or manipulating hardware registers.
There are three types of bit shift operations supported by this calculator. Left shift (<<) moves all bits to the left, filling the right side with zeros. Each shift left effectively multiplies the value by 2. Signed right shift (>>) moves bits to the right while preserving the sign bit — this means negative numbers stay negative. Unsigned right shift (>>>) also moves bits right but fills the leftmost bits with zeros regardless of the sign, which can produce very different results for negative inputs.
Left shift is the go-to trick for fast multiplication by powers of two. In systems where every CPU cycle counts — like audio DSP or real-time physics simulation — I use x << 3 instead of x * 8. The compiler might do this optimization anyway, but writing it explicitly makes the intent clear. Beware of overflow: pushing a 1 into bit 31 flips the sign bit, and shifting past bit 31 loses bits entirely.
Signed right shift is common for fast integer division by powers of two. The catch is that it rounds toward negative infinity, not toward zero. For positive numbers this doesn't matter, but for negative numbers the behavior differs from integer division in most languages. -5 >> 1 gives -3 (floor of -2.5), while C-style integer division gives -2 (truncation toward zero).
Unsigned right shift is my favorite debugging trick. When I need to inspect a value as raw bits without sign extension, >>> gives a clean zero-fill shift. It's also essential when working with color channels in graphics programming — shifting a packed pixel value right by the right amount extracts each color component cleanly.
1 << N gives 2^N. 1 << 10 = 1024(value >> N) & 1 extracts the Nth bit(pixel >> 16) & 0xFF gets the red channel from a 32-bit ARGB value(value << 24) >> 24 sign-extends an 8-bit value to 32 bitsflags |= (1 << N) sets bit N; flags &= ~(1 << N) clears itLeft shift (<<) moves bits to the left, filling zeros on the right — equivalent to multiplying by 2^N. Right shift (>>) moves bits to the right, discarding low bits — equivalent to floor division by 2^N for positive numbers. JavaScript's >> preserves the sign bit (sign-propagating), while >>> fills with zeros regardless of sign.
JavaScript bitwise operators work on 32-bit signed integers. When the shift amount is 32 or greater, JavaScript uses only the lower 5 bits (shift & 0x1F), effectively wrapping the shift amount modulo 32. For example, 1 << 32 becomes 1 << 0 = 1, not 0 as you might expect. Try it in this calculator to see the effect.
Unsigned right shift (>>>) always fills the leftmost bits with zeros, regardless of the sign of the number. Regular right shift (>>) preserves the sign bit — negative numbers stay negative because the left side is filled with 1s. For positive numbers, both produce the same result. For negative numbers, >>> can produce very large positive results since the sign bit becomes 0.
Left shifting by N is equivalent to multiplying by 2^N as long as no bits overflow. Right shifting by N is equivalent to floor division by 2^N for positive numbers. For example, 5 << 3 = 5 x 8 = 40, and 40 >> 3 = 40 / 8 = 5. This technique is used in performance-critical code where multiplication and division are expensive.