Bit Shift Calculator
Calculate left and right bit shift operations
Table of Contents
How to Use
- Enter the number to shift
- Enter the shift amount
- Select left shift (<<) or right shift (>>)
- Click calculate to see the result
What is Bit Shifting?
Bit shifting is a bitwise operation that moves the bits of a binary number left or right by a specified number of positions. It's a fundamental operation in computer programming and digital electronics.
Types of Bit Shifts
Left Shift (<<)
Moves bits to the left, filling empty positions with zeros. Equivalent to multiplying by 2 for each shift position.
Example: 5 << 2 = 20 (binary: 101 << 2 = 10100)
Right Shift (>>)
Moves bits to the right, discarding bits that fall off. Equivalent to integer division by 2 for each shift position.
Example: 20 >> 2 = 5 (binary: 10100 >> 2 = 101)
Frequently Asked Questions
- What's the difference between left and right shift?
- Left shift (<<) multiplies the number by 2^n, while right shift (>>) divides by 2^n (integer division), where n is the shift amount.
- Why use bit shifting instead of multiplication/division?
- Bit shifting is much faster than multiplication or division in computer processors, making it useful for performance-critical code.
- What happens to bits that shift off the end?
- In left shift, bits that shift beyond the number's size are lost. In right shift, the rightmost bits are discarded.