Calculators

Binary Shift Calculator

Calculate fixed-width logical left, logical right and arithmetic right binary shifts with exact signed and unsigned decimal results.

Shift 1 to 4096 bits within the entered width; leading zeros count. Logical shifts fill with zeros. Arithmetic right shifts repeat the original sign bit. Bits shifted out are discarded. Calculations stay in your browser.

Enter binary digits and a shift count.

How fixed-width binary shifts work

A logical left shift discards bits from the left and fills the right with zeros. A logical right shift discards bits from the right and fills the left with zeros. An arithmetic right shift repeats the original most significant bit, preserving the sign in two’s complement. For 1011 shifted by one, logical left gives 0110 (unsigned 6), logical right gives 0101 (5), and arithmetic right gives 1101 (unsigned 13; signed -3). The original four-bit 1011 represents signed -5. Arithmetic right shift rounds signed division by powers of two toward negative infinity. Left shifts retain only the entered width, so overflow is discarded. Leading zeros define the width. A zero count leaves the word unchanged; counts equal to or greater than the width give all zeros for logical shifts and all sign bits for arithmetic right shifts. Counts are not reduced modulo width. Enter 1 to 4096 binary digits and a nonnegative count of up to 1000 decimal digits. Surrounding whitespace is accepted; prefixes, internal spaces, signs, fractions and scientific notation are rejected. Signed output always interprets the result as a fixed-width two’s complement value. Calculations run entirely in your browser without 32-bit truncation.

Frequently Asked Questions

Everything you need to know about this tool, how it works, and privacy.

What is the difference between logical and arithmetic right shift?

Logical right shift inserts zeros. Arithmetic right shift repeats the original sign bit. For 1011 shifted by one they give 0101 and 1101 respectively.

What happens when the shift count reaches the word width?

Logical shifts give all zeros. Arithmetic right shifts give all ones for an original leading 1, or all zeros for an original leading 0. Larger counts have the same result.

Do leading zeros affect the calculation?

Yes. They define the word width and determine the sign bit. For example, 0011 is a positive four-bit value, while 11 represents signed -1 in two bits.

How are shifts different from rotations?

Shifts discard outgoing bits and insert zeros or sign bits. Rotations wrap outgoing bits to the opposite end.

Why can the signed and unsigned results differ?

Both describe the same output bits. A leading 1 represents a negative value under fixed-width two’s complement interpretation, but a positive value under unsigned interpretation.