Bit Shift Calculator
Result
Shifted Value 48
Result (binary) 110000
Original (binary) 1100
Shift the bits of an integer left or right by a chosen number of positions and see the result in decimal and binary. A left shift multiplies by powers of two; a right shift divides (rounding toward zero).
Formula
left: value << n = value × 2ⁿ · right: value >> n = ⌊value ÷ 2ⁿ⌋
- A left shift (<<) moves every bit n places toward the high end, filling with zeros — equivalent to multiplying by 2 to the power n.
- A right shift (>>) moves bits toward the low end, discarding the bits that fall off — equivalent to integer division by 2 to the power n.
- Values are truncated to whole numbers, since bit shifts operate on integers.
- Shifts use 32-bit signed integer arithmetic, matching how the << and >> operators behave in most languages.
- The binary outputs are shown as unsigned 32-bit patterns so negative results display their full bit representation.
12 << 2
Inputs
- Integer Value: 12
- Shift Positions: 2
- Direction: left
12 in binary is 1100. Shifting left by 2 gives 110000, which is 48 — the same as 12 × 2².
Frequently asked questions
What does a left shift do?
It slides every bit toward the most-significant end and pads the empty low bits with zeros. Each position shifted multiplies the value by 2, so << n multiplies by 2ⁿ.
What does a right shift do?
It slides bits toward the least-significant end, dropping the bits that fall off the right. For non-negative numbers this is integer division by 2ⁿ.
Why are bit shifts useful?
They are very fast ways to multiply or divide by powers of two, pack and unpack data, and manipulate flags — common in low-level and performance-critical code.
How are negative numbers handled?
Shifts use 32-bit signed arithmetic. The decimal result follows JavaScript's >> (sign-propagating) operator, while the binary view shows the unsigned 32-bit pattern.
What is the maximum shift?
This calculator allows 0 to 31 positions, matching 32-bit integer operations. Shifting by 32 or more wraps around in most languages.