StatGardenREF. DESK
Calculators/Maths/Bit Shift Calculator
Maths

Bit Shift Calculator

Shifts an integer left or right by a chosen number of bits, showing the result in decimal and binary.

Published 31 August 2026

What this calculator does

A bit shift moves every bit in a binary number left or right by a set number of positions, dropping bits that fall off the end and filling the vacated positions with zeros. Shifting left by n positions multiplies the value by 2 to the power of n; shifting right by n positions divides it by 2 to the power of n and rounds down, discarding the remainder.

Bit shifts turn up throughout programming as a fast way to multiply or divide by powers of two, to pack several small values into one integer, and to read or set individual flag bits. They are exact and lossless for left shifts (within the range a data type can hold) but right shifts on an odd number always lose information, since the fractional part is simply dropped.

The formula

FormulaLeft shift: value × 2^n; Right shift: floor(value / 2^n)

Enter the integer value, choose left or right, and the number of bit positions to shift. A left shift computes value × 2^n exactly. A right shift computes floor(value ÷ 2^n): the integer division discards any remainder rather than rounding to the nearest whole number.

TermMeaning
Left shiftMoves bits toward the higher end, equivalent to multiplying by 2^n.
Right shiftMoves bits toward the lower end, equivalent to dividing by 2^n and discarding the remainder.
nThe number of bit positions to shift by.

The inputs explained

FieldWhat to enter
Integer valueThe whole number to shift, entered in ordinary decimal. Must be zero or positive.
Shift directionWhether to shift the bits left (multiply) or right (divide, rounding down).
Number of bit positions to shiftHow many bit positions to shift by.

When to use it

Multiplying or dividing by a power of two quickly

Left-shifting by 1 doubles a value, by 2 quadruples it, and so on; right-shifting halves it (rounding down). This is how low-level code often multiplies or divides by powers of two faster than a general multiplication.

Packing flags or small fields into one integer

Shifting a value left by a fixed amount before combining it with other bits, using a bitwise OR, is the standard way to pack several small fields into a single integer for storage or transmission.

Checking how a right shift truncates

Right-shifting an odd number always drops information, since the bit shifted out represents the remainder. Working through a specific value shows exactly which bit is lost and what the floored result becomes.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How left-shifting an integer by increasing amounts changes its value

The value 22 shifted left by a range of bit positions.

Starting value 22, left shift
Shift amount (bits)Result (decimal)Result (binary)
1 bits44101100
2 bits881011000
3 bits17610110000
4 bits352101100000
5 bits7041011000000
6 bits1,40810110000000
Each extra bit position doubles the previous result, since a left shift by n is the same as multiplying by 2^n.

Questions

What happens to bits shifted off the end?

They are simply discarded. A left shift that pushes bits past the width of the data type being used loses them permanently, which is why left shifts can silently overflow in a fixed-width integer type even though this calculator itself has no such limit.

Does a right shift round to the nearest value?

No, it always rounds down (floors), never to the nearest integer. Right-shifting 7 by 1 gives 3, not 3.5 or 4, because the fractional remainder from the division is dropped, not rounded.

Why does this calculator require a non-negative value?

How a shift behaves on negative numbers depends on the specific representation used, such as two's complement and whether the shift is arithmetic or logical. This calculator sticks to the unambiguous unsigned case; use a two's complement calculator for signed binary representations.

Is a left shift always the same as multiplying?

Mathematically yes, value × 2^n, but in real programming languages a left shift on a fixed-width integer type can overflow and wrap around in ways ordinary multiplication on a larger type would not, so the two are not always interchangeable in code.

For converting a signed integer into its binary two's-complement form at a chosen bit width, see the two's complement calculator.