How this calculator works
A bit shift moves every bit a fixed number of places inside the chosen width. A left shift pushes bits toward the most significant end: each place doubles the value, and bits that pass the top of the width are discarded. A right shift pushes bits toward the least significant end: each place halves the value and drops the discarded low bits, which is why it acts like division that throws away the remainder. This calculator performs a logical right shift on the unsigned bit pattern, so zeros enter at the top. The "bits shifted out" line shows exactly which bits were lost, reading from the highest discarded position to the lowest.
Formula
Left shift by k: result = (x × 2ᵏ) mod 2ⁿ. Right shift by k: result = floor(x / 2ᵏ). Here n is the bit width and x is read as an unsigned integer before shifting.
Worked example
In 8 bits, 00001101 (13) shifted left by 1 becomes 00011010 (26), and the single bit shifted out is 0. Shifting the same value right by 2 gives 00000011 (3) and discards the two low bits 01. In 4 bits, 1111 shifted left by 1 becomes 1110 (14), and the bit shifted out is 1.
Advertisement
Frequently asked questions
Is a right shift the same as dividing by a power of two?
For a non-negative unsigned value, yes, with the remainder dropped. For example, 13 shifted right by 2 gives 3, the same as floor(13 / 4). Signed arithmetic right shifts can differ because they copy the sign bit, but this calculator shifts the unsigned bit pattern.
What happens when I shift left past the top bit?
Those bits are discarded and the result wraps inside the chosen width. The discarded line lists them, so 1010 in 4 bits shifted left by 4 gives 0000 and discards 1010. This is the usual fixed-width register behaviour.
Why can I not shift more places than the bit width?
A shift of n places in an n-bit width has already removed every bit, so any larger shift gives the same zero result. Limiting the input to the width keeps the discarded-bit display meaningful.
Does the input base change the result?
No. Binary, octal and decimal are only ways of writing the same whole number. The number is converted to its bit pattern first, then shifted, so the result is identical whichever base you use.