# Bit Shift Calculator

URL: https://speedycalculator.com/calculators/math/bit-shift/
Last updated: 2026-11-08

> The bit shift calculator shifts a binary, octal or decimal number left, logically right or arithmetically right by any number of positions in a fixed bit width, showing the bits before and after.

## Inputs

- Representation
- Number format
- Number
- Direction
- Number of positions

## Results

- Result (binary)
- Before the shift
- Result (decimal, unsigned)
- Result (decimal, signed)
- Result (octal)

## Formula

```
x << n = x·2ⁿ (bits shifted out are lost) · x >>> n = ⌊x/2ⁿ⌋ (zeros enter) · x >> n keeps the sign bit
```

## Explanation

Shifting bits is the fastest way for a processor to multiply or divide by powers of two. It is used in hashing, graphics, compression, cryptography and to extract fields from packed binary data.

### How to use the Bit Shift Calculator

- **Representation**
- **Number format**
- **Number**
- **Direction**
- **Number of positions**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

Choose the bit width, input format, direction and number of positions. A left shift drops bits that fall off the top; a logical right shift fills with zeros; an arithmetic right shift copies the sign bit so negative numbers stay negative.

## Worked example

Inputs: Representation: 8-bit; Number format: Binary; Number: 00010111; Direction: Left (<<); Number of positions: 2.

Results: **Result (binary) = 0101 1100**; Before the shift = 0001 0111; Result (decimal, unsigned) = 92; Result (decimal, signed) = 92; Result (octal) = 134.

## Key terms

- **Arithmetic shift**: A right shift that preserves the sign bit.

## FAQ

**What does a left shift by 1 do?**
Doubles the number (as long as no bit falls off).

**What is the difference between >> and >>>?**
>> keeps the sign (arithmetic); >>> fills with zeros (logical).

**What happens to bits shifted out?**
They are discarded.

**Is shifting faster than multiplying?**
On simple processors yes; modern compilers do it automatically.


## Sources

- [Wolfram MathWorld: Binary](https://mathworld.wolfram.com/Binary.html)
- [Harvard CS50: Binary and bitwise operators](https://cs50.harvard.edu/x/)
