Bit Shift Calculator
Logical and arithmetic shifts and rotations on 8–64-bit words.
What it does
Shifts or rotates the bits of a number left or right, with logical and arithmetic shifts and rotations on 8- to 64-bit words.
Where it's used
Fast multiply/divide by powers of two, packing bit fields, checksums and hashing.
How to use it
- Type the value (decimal, hex or binary).
- Choose the operation.
- Enter the shift amount and word size.
The formula explained
- x ≪ k
- x × 2ᵏ (bits falling off the top are lost)
- x ≫ k
- ⌊x / 2ᵏ⌋, filling with 0 (logical)
- Arithmetic ≫
- fills with copies of the sign bit
- Rotate
- bits that fall off re-enter on the other side
Worked example
Rotating 0x81 right by one bit.
Inputs:
- Value: 0x81
- Operation: ⟳ Rotate right
- Shift amount: 1 bits
- Word size: 8-bit
The calculator gives:
- Decimal (unsigned): 192
- Decimal (signed): -64
- Hexadecimal: 0xC0
Tips and common mistakes
- Use arithmetic right shift for signed numbers.
- Shifting by the full word size or more is undefined behaviour in C.
- Rotations keep every bit — nothing is lost.
Questions people ask
Is a shift the same as multiplying or dividing?
Shifting left by n multiplies by 2^n, as long as no bits fall off the top. Arithmetic shifting right by n divides by 2^n, rounding down — so −5 ≫ 1 is −3, not −2.
What is the difference between logical and arithmetic right shift?
A logical shift fills the top with 0s; an arithmetic shift copies the sign bit. In 8 bits, 0x80 ≫ 1 is 0x40 (64) logically but 0xC0 (−64) arithmetically.
How do I rotate bits in C?
C has no rotate operator, but (x >> n) | (x << (8 − n)) on a uint8_t (with 0 < n < 8) rotates right, and compilers turn it into a single rotate instruction.
Related Digital Logic calculators
- Binary Calculator
- Number System Converter
- Logic Gate Calculator
- Two's Complement Calculator
- Parity Bit Calculator
- Hamming Code Calculator
- Truth Table Generator
- Karnaugh Map Solver
- Gray Code Converter
- Bitwise Calculator
Enter your values to get the result with the formula, substituted values and an explanation of each step.