Bit Shift Calculator

Shift an integer's bits left or right inside an 8, 16, or 32-bit register and see the decimal, binary, and hexadecimal result — the same operation CPUs use for fast multiplication and division by powers of two.

Quick Facts

Left shift
X << n = X × 2ⁿ
Exact as long as the result still fits the chosen bit width.
Arithmetic right shift
X >> n = floor(X ÷ 2ⁿ)
Sign-extends, so negative numbers stay negative.

Results

Calculated
Shifted value (decimal)
Signed result
Binary
Two's complement bit pattern
Hexadecimal
Base-16 representation
Equivalent arithmetic
Multiplication / division form

Ready

Set a value, shift amount, direction, and bit width, then press Calculate.

How to use this calculator

Enter an integer Value, choose how many bit positions to shift, pick the shift direction/type, and choose the register width (8, 16, or 32 bits) the shift operates within. Click Calculate to see the shifted value in decimal, binary, and hexadecimal. Click Clear to reset all fields to the defaults.

What a bit shift does

A bit shift moves every bit in a number's binary representation left or right by a fixed number of positions. A left shift (X << n) moves bits toward higher place values and fills the emptied low bits with zeros — this is exactly the same as multiplying X by 2n, as long as the result still fits inside the chosen register width. A right shift moves bits toward lower place values, which is equivalent to integer division by 2n. There are two kinds of right shift: an arithmetic right shift (X >> n) fills the emptied high bits with copies of the original sign bit, so negative numbers stay negative and the result rounds toward negative infinity; a logical/unsigned right shift (X >>> n) always fills with zeros, treating the bit pattern as an unsigned number. Negative numbers are represented using standard two's complement encoding within the chosen bit width.

Interpreting the results

Shifted value (decimal) is the signed integer result of the shift. Binary shows the exact bit pattern, zero-padded to the register width, so you can see which bits moved. Hexadecimal is the same bit pattern written in base 16. Equivalent arithmetic restates the shift as a multiplication or division by a power of two, and flags it when a left shift has overflowed the register (some high-order bits were discarded, so the shifted value no longer matches simple multiplication).

Frequently Asked Questions

What does a left shift (<<) do?
A left shift moves every bit toward higher place values and fills the vacated low bits with zeros. Shifting left by n positions is equivalent to multiplying by 2^n, as long as the result still fits in the chosen bit width. For example, 5 << 2 = 20, because 5 x 4 = 20. If the result would need more bits than the register holds, the high-order bits are discarded and the value wraps (overflow).
What is the difference between arithmetic and logical right shift?
An arithmetic right shift (>>) fills the vacated high bits with copies of the sign bit, so it preserves the sign of the number and is equivalent to dividing by 2^n and rounding toward negative infinity. A logical (unsigned) right shift (>>>) always fills with zeros, treating the bit pattern as unsigned. The two produce identical results for non-negative numbers and differ only when the starting value is negative.
Why do I need to choose a bit width?
A shift happens inside a fixed-size register - 8, 16, or 32 bits here - and that width determines both how negative numbers are encoded (two's complement) and how many bits are available before high-order bits get shifted out and discarded. The same shift on the same decimal value can give a different binary result, and even a different overflow behavior, depending on the register width.
Is left-shifting always the same as multiplying by a power of two?
Only while the result stays within the selected bit width. X << n equals X times 2^n exactly when no significant bits are lost. Once the shifted value needs more bits than the register provides, the top bits are truncated and the stored result no longer matches the plain multiplication - this calculator flags that case as an overflow.