Binary Right Shift Calculator – Free

This right shift calculator moves the bits of a binary number toward the least significant end and drops the bits that fall off. The input is treated as unsigned, so zeros enter from the left.

How to use the Right shift Calculator tool

  1. Type the number to shift into the Binary digits field, for example 10110001.
  2. Set the Number of positions field to a whole number from 0 to 4096.
  3. Select Right-shift. Selecting Example runs 10110001 shifted by 2.
  4. Read the remaining bits in the Result box.
  5. Select Copy to copy the value, or Clear to reset both fields.

How a binary right shift works

A right shift by n removes the n lowest bits and slides the others down to take their place. For an unsigned value this is integer division by 2^n with the remainder thrown away. Shifting 10110001, which is 177, right by 2 leaves 101100, which is 44: 177 divided by 4 is 44 with a remainder of 1.

The calculator prints the result as a plain number, without leading zeros. If the shift count is equal to or larger than the number of significant bits, everything is shifted out and the result is 0.

10110001 >> 2  =  101100   (177 / 4 = 44, remainder dropped)
11010110 >> 4  =  1101     (high nibble)
10110001 >> 8  =  0

Logical versus arithmetic right shift

There are two kinds of right shift, and they differ only in what enters at the top. A logical shift inserts zeros. An arithmetic shift copies the sign bit, so a negative two's complement number stays negative and the result rounds toward negative infinity.

This tool performs the logical kind, because it reads the input as an unsigned value with no sign bit. As an 8-bit signed byte, 10110001 is -79, and an arithmetic shift by 2 would give 11101100, or -20. Here the answer is 101100. JavaScript and Java have a separate operator for each form. In C, C++, Go and Rust the operand's type decides: unsigned types shift logically and signed types, in practice, arithmetically.

Extracting bit fields with a right shift

The most common use of a right shift in real code is pulling a field out of a packed word: shift the field down to bit 0, then mask off the bits above it. To read the high nibble of 11010110, shift right by 4 and you get 1101. Register maps, network headers, color channels in a 32-bit pixel and instruction decoders all rely on this pattern.

Input rules and limits

The shift only runs when both fields are valid, so check these rules if you see an error.

  • Binary digits takes 1 to 65,536 characters of 0 and 1, with an optional 0b prefix. Spaces are removed.
  • Number of positions must be a whole number between 0 and 4096. An empty or fractional value is rejected.
  • A shift of 0 returns the input value with leading zeros removed.
  • Bits shifted out are gone. The tool does not report them as a remainder or carry.

Frequently asked questions

Is a right shift the same as dividing by 2?

For unsigned numbers, yes: each position halves the value and discards the remainder. For negative signed numbers an arithmetic shift rounds toward negative infinity, while integer division in C and Java rounds toward zero, so the results can differ by one.

Does this calculator do an arithmetic right shift?

No. It always shifts in zeros, because the input is read as unsigned. To get the arithmetic result for a negative word, replace the vacated top positions with copies of the original sign bit by hand.

Why did my result lose its leading zeros?

The output is a number, not a fixed-width word. 00101100 shifted right by 3 is printed as 101. Pad the result on the left with zeros to the width of your register if you need aligned columns.

What happens if I shift by more positions than there are bits?

The result is 0. Every bit has moved past the least significant position and been discarded. This differs from C, where shifting a value by its full type width or more is undefined behavior.

How do I undo a right shift?

You cannot fully undo it, because the discarded low bits are lost. A left shift by the same amount restores the surviving bits to their old positions and fills the bottom with zeros.

Related tools