Bit Shift Calculator
Test cases replayed : 3 of 3 match · Methodology · No outside source listed
Enter a non-negative whole number, the number of positions and the direction of the shift.
Result
Result in decimal
n in binary (shown up to 16 digits)
- Result in binary (shown up to 16 digits)
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Number n (decimal, 0 to 4,294,967,295): enter 0 or more.
- Shift by k positions (0 to 32): enter a number from 0 to 32.
- Direction: choose Left shift (n << k) or Right shift (n >> k).
- Read the result: Result in decimal; the panel also shows n in binary (shown up to 16 digits) and Result in binary (shown up to 16 digits).
How this calculator works
A left shift by k moves every bit k places to the left and fills with zeros: n << k = n × 2ᵏ. A logical right shift drops the last k bits: n >> k = floor(n ÷ 2ᵏ).
The calculator works on non-negative whole numbers without a fixed width, so a left shift never overflows here; in a 32-bit register, bits pushed past the top would be lost.
Worked example
| Number n (decimal, 0 to 4,294,967,295) | 13 |
|---|---|
| Shift by k positions (0 to 32) | 2 |
| Direction | Left shift (n << k) |
| Result in decimal | 52 |
|---|---|
| n in binary (shown up to 16 digits) | 1101 |
| Result in binary (shown up to 16 digits) | 110100 |
Frequently asked questions
What is 13 << 2?
52: 1101 becomes 110100, which is 13 × 4.
What is 200 >> 3?
25: 11001000 becomes 11001, which is 200 ÷ 8.