Binary Bit Right-Shifter
Right-shift binary, decimal, or hex values with visual bit animation. Supports logical and arithmetic shifts for 8, 16, 32, and 64-bit widths.
About
A right bit-shift displaces every bit in a binary word toward the least-significant position by n places. The n least-significant bits are discarded. What fills the vacated most-significant positions determines the shift type: a logical shift inserts 0s, while an arithmetic shift replicates the original sign bit. Confusing the two produces silently wrong results in signed arithmetic. Dividing a signed negative integer with a logical shift instead of an arithmetic one yields a large positive number rather than the expected negative quotient. This tool performs both shift variants across 8, 16, 32, and 64-bit widths with full two's complement representation, so you can verify firmware masks, protocol headers, or compiler output without risking a subtle off-by-one in production code.
Input accepts binary, decimal, or hexadecimal notation. The bit-level visualization color-codes retained, dropped, and filled positions so the mechanical effect of the shift is immediately visible. Note: results assume a fixed-width register. Overflow and sign extension behave exactly as they would in a hardware ALU of the selected width.
Formulas
The logical right shift by n positions on a w-bit unsigned value:
The arithmetic right shift preserves the sign bit s. For a w-bit two's complement integer:
where the fill mask is:
Where value is the input integer, n is the shift amount (0 โค n โค w), w is the register width in bits, and s is the most-significant bit (sign bit) of the original value. Arithmetic right-shift of a negative number rounds toward negative infinity, not toward zero.
Reference Data
| Shift Amount | 8-bit Logical (unsigned 200) | 8-bit Arithmetic (signed โ56) | Equivalent Division | Bits Dropped |
|---|---|---|---|---|
| 0 | 11001000 โ 200 | 11001000 โ โ56 | รท 1 | 0 |
| 1 | 01100100 โ 100 | 11100100 โ โ28 | รท 2 | 1 |
| 2 | 00110010 โ 50 | 11110010 โ โ14 | รท 4 | 2 |
| 3 | 00011001 โ 25 | 11111001 โ โ7 | รท 8 | 3 |
| 4 | 00001100 โ 12 | 11111100 โ โ4 | รท 16 | 4 |
| 5 | 00000110 โ 6 | 11111110 โ โ2 | รท 32 | 5 |
| 6 | 00000011 โ 3 | 11111111 โ โ1 | รท 64 | 6 |
| 7 | 00000001 โ 1 | 11111111 โ โ1 | รท 128 | 7 |
| 8 | 00000000 โ 0 | 11111111 โ โ1 | รท 256 | 8 |
Frequently Asked Questions
int64_t or Java's long without JavaScript's 32-bit truncation artifacts.