Bit Shift Calculator

Perform left and right bit shift operations with step-by-step explanations

Bit Shift Calculator

Number of bits for calculation and result representation

Enter decimal number

Left shift multiplies by powers of 2

Number of positions to shift (0 to 8)

Example Bit Shifts

Left Shift Examples

5 << 1 = 10
0101 → 1010
3 << 2 = 12
0011 → 1100

Left shift by n positions = multiply by 2^n

Right Shift Examples

12 >> 1 = 6
1100 → 0110
20 >> 2 = 5
10100 → 00101

Right shift by n positions = divide by 2^n

Bit Shift Rules

Left Shift (<<)

  • • Moves bits to the left
  • • Fills right with zeros
  • • Multiplies by 2^n
  • • May cause overflow

Right Shift (>>)

  • • Moves bits to the right
  • • Arithmetic shift (preserves sign)
  • • Divides by 2^n
  • • Rounds down for positive numbers

Powers of 2

2^0=1
2^1=2
2^2=4
2^3=8
2^4=16
2^5=32
2^6=64
2^7=128

Bit Shift Tips

Left shift is fast multiplication by powers of 2

Right shift is fast division by powers of 2

Watch for overflow in left shifts

Arithmetic right shift preserves sign

Understanding Bit Shift Operations

What are Bit Shifts?

Bit shifting is a bitwise operation that moves the bits of a binary number to the left or right by a specified number of positions. It's a fundamental operation in computer science and digital electronics.

Applications:

  • • Fast multiplication and division by powers of 2
  • • Memory optimization in programming
  • • Digital signal processing
  • • Graphics and image processing
  • • Cryptography and hash functions

Types of Bit Shifts

Logical Left Shift

Moves bits left, fills with zeros on the right. Equivalent to multiplication by 2^n.

Arithmetic Right Shift

Moves bits right, preserves the sign bit for negative numbers. Equivalent to division by 2^n.

Overflow Behavior

When bits are shifted beyond the available bit width, they are lost. Left shifts can cause overflow, while right shifts may lose precision.