Skip to main content
Data / Number / Computer Science Tools

Bit Shift Calculator

Calculate left and right bit shifts - clearly distinguishes arithmetic (sign-preserving) from logical (zero-fill) right shift.

Enter a number and a shift amount - this tool calculates left shift, arithmetic right shift, and logical right shift, showing how they differ.

Arithmetic right shift preserves the sign bit (fills with 1s for negative numbers) - logical/unsigned right shift always fills with 0s, treating the value as unsigned. Shift counts are limited to 0-31 since JavaScript's bitwise operators work on 32-bit integers.

Arithmetic right shift preserves the sign bit (useful for signed integers); logical right shift always fills with zeros (used for unsigned values) - the difference only matters for negative numbers.

Arithmetic vs. Logical Right Shift

A left shift (<<) always fills vacated bits with zero. A right shift has two variants: arithmetic (>>) fills vacated bits with copies of the sign bit (preserving whether the number is negative), while logical (>>>) always fills with zeros regardless of sign.

How to Use It

  1. Enter an integer and a shift amount.
  2. View the left shift, arithmetic right shift, and logical right shift results side by side, with binary representations.

Limitations

Uses JavaScript's native 32-bit shift operators, matching standard integer shift behavior in most languages - shift amounts are taken modulo 32, and invalid (non-integer) shift counts are rejected rather than silently truncated.

Share this tool: