Bit Shift Calculator
Calculate left and right bit shifts with visual representation.
Understanding Bit Shifts
Left Shift (<<)
Shifts bits to the left, filling with zeros on the right. Equivalent to multiplying by 2^n.
5 << 2 = 20 (5 × 4)Right Shift (>>)
Shifts bits to the right. Logical shift fills with zeros; arithmetic shift preserves the sign bit.
20 >> 2 = 5 (20 ÷ 4)Code Examples
const a = 5; // 0101
a << 1; // 10 (1010) - multiply by 2
a << 2; // 20 (10100) - multiply by 4
a >> 1; // 2 (0010) - divide by 2
a >>> 1; // 2 (logical right shift)Frequently Asked Questions
What does bit shifting do?
Left shift (<<) moves bits left, filling with zeros. Equivalent to multiplying by 2^n. Right shift (>>) moves bits right, equivalent to dividing by 2^n (integer division).
What's the difference between logical and arithmetic shift?
Logical shift fills with zeros. Arithmetic right shift preserves the sign bit (fills with 1s for negative numbers). Left shift is the same for both.
Related Tools
Bitwise Calculator
Perform bitwise operations: AND, OR, XOR, NOT, NAND, NOR - or evaluate full expressions like 0xFF & 0b1010 << 2.
Bitmask Generator & Register Workbench
Build, paste and visualize bitmasks at 8, 16, 32 or 64 bits - then generate the set, clear, toggle and field-extract code for them.
Two's Complement Calculator
Calculate two's complement representation for signed integers.
This tool runs entirely in your browser - nothing you enter is uploaded or stored.