Bit Shift Calculator: Left & Right Shift, Logical vs Arithmetic

Bit Shift Calculator

Shift any value left or right and watch the bits move. A left shift by n multiplies by 2 to the n power, a right shift divides by 2 to the n and floors the result, and the tool shows both logical and arithmetic right shifts for signed values along with any high bits that overflow the chosen 8, 16, or 32 bit width.

Real Shift Presets

🔢Shift Inputs

The number whose bits will move. Signed values may be negative.

How the value above is read. Prefixes 0b and 0x are optional.

Left moves bits toward the MSB, right moves them toward the LSB.

How many positions to shift. Equivalent to 2 to the n scaling.

Sets the register size. Bits shifted past the top overflow and drop.

Only affects right shifts. Arithmetic copies the sign bit inward.

Signed reads the top bit as a sign for negative values.

Toggles the before and after bit pattern and math breakdown.

Shifted Result 0 decimal value
Binary 0 grouped, width limited
Hexadecimal 0x0 base 16 form
Equivalent Math x1 scale factor

📊Shift Cheat Sheet

<<nx 2^n
>>nfloor / 2^n
>>>fill zero
1<<n2 to the n

🔢Left Shift Powers of Two

ExpressionMultiplier1 ShiftedBinary of 1 << n
x << 0x 110000 0001
x << 1x 220000 0010
x << 2x 440000 0100
x << 3x 880000 1000
x << 4x 16160001 0000
x << 5x 32320010 0000
x << 6x 64640100 0000
x << 7x 1281281000 0000

📏Right Shift Divides and Floors

ExpressionDivisorExampleResultNote
x >> 1/ 29 >> 14Floors, drops 0.5
x >> 2/ 425 >> 26Floors, drops 0.25
x >> 3/ 81024 >> 3128Exact division
x >> 4/ 16255 >> 415Keeps high nibble
x >> 5/ 32100 >> 53Floors, drops rem
x >> 8/ 25665535 >> 8255Extracts high byte
x >> 10/ 10244096 >> 104Bytes to KiB scale

🔑Logical vs Arithmetic Right Shift

OperatorFills WithSign Kept-8 (8-bit)Shift 1
>> arithmeticCopy sign bitYes1111 10001111 1100 = -4
>>> logicalZeroNo1111 10000111 1100 = 124
>> on +veZero either wayN/A0000 10000000 0100 = 4
>>> on +veZeroN/A0000 10000000 0100 = 4
<< leftZero at LSBSame both1111 10001111 0000 = -16
>> -1Copy sign bitYes1111 11111111 1111 = -1

🗃Shift Operation Comparison Grid

ValueOpnResultBinaryEquiv Math
1<<4160001 00001 x 16
255<<15101 1111 1110255 x 2
8>>220000 00108 / 4
1024>>31281000 00001024 / 8
-8>>1-41111 1100-8 / 2 arith
0x0F<<42401111 000015 x 16
100>>1500011 0010100 / 2
3<<5960110 00003 x 32
7<<2280001 11007 x 4
65535>>82551111 1111high byte

Formula Breakdown

Left shift A << nEvery bit moves n places toward the most significant bit and n zeros fill the low end. Numerically this is A times 2 to the n, so 1 << 4 = 1 x 16 = 16.
Right shift A >> nEvery bit moves n places toward the least significant bit. This equals the floor of A divided by 2 to the n, so 9 >> 1 = floor(9 / 2) = 4, dropping the remainder.
Power of two 1 << nShifting a single 1 bit left by n builds the value 2 to the n exactly, a fast way to make masks and flags: 1 << 8 = 256.
Logical right >>>The vacated top bits are always filled with zeros. For -8 in 8 bits (1111 1000), a logical shift by 1 gives 0111 1100 = 124, ignoring the sign.
Arithmetic right >>The vacated top bits copy the original sign bit so negatives stay negative. -8 >> 1 gives 1111 1100 = -4, matching floored division by 2.
Overflow on left shiftBits pushed past the chosen width fall off. In 8 bits, 255 << 1 keeps only 1111 1110 = 254 and the top 1 bit is dropped as overflow.

💡Practical Shift Tips

Shift instead of multiply or divide: When scaling by a power of two, x << 3 replaces x times 8 and x >> 2 replaces dividing by 4, and both run in a single fast machine instruction. Just remember right shift floors toward zero for unsigned values, so 7 >> 1 gives 3, not 3.5.
Mind the width and the sign: A left shift that pushes bits past 8, 16, or 32 positions silently overflows and drops them, so 1 << 8 in an 8-bit byte becomes 0. For negative numbers pick arithmetic right shift to preserve the sign; logical shift on -1 turns it into a large positive value like 2147483647.

Once you look at each bit in isolation, though, bit shifting looks easy: just multiply by powers of two (a left shift) or divide by powers of two (a right shift). Just pick direction and width, and the calculator will process it into something real. Enter your value, decide how far to shift it then sit back and watch your bits dance around on-screen.

Particularly with large values, this let you visually track where all the digits go, which ones stay and which ones slide past end of the register. But then every integer has a limited space: a thirty-two bit word; an eight-bit byte. And when you shift those bits around they press against the ceiling of that box. Eventually there isn’t any more room, it spills over the edge. That’s called overflow.

How Bit Shifting Works

It happens because this is how computers store stuff, not because of a mathematical mistake. You can use the tool to switch back-and-forth between registers with eight bits, sixteen bits, and thirty-two bits, and see where that boundary live.

So 255 shifted left by one place (in an eight-bit register) ought to be five-hundred-ten, right? But there isn’t room! There’s only enough space for two-hundred-fifty-five. And the top bit falls off, two-hundred-fifty-four. Which might surprise you if you’re unprepared.

The left shift operator act as a clean multiplier. Eight times x = x > 1 isn’t four and a half, it’s just four. That fraction gets dropped. This is good if you want to scale something down or do some other task with array indices where having a fraction of a pixel isn’t necessary. Keep in mind: computers don’t do remainder calculations by default, only when asked to, because they know you might not need it.

The decision to make left and right shifts either arithmetic or logical causes issues with negative numbers. With an arithmetic right shift, the sign bit is copied up into the newly created space on top, which maintains the division of negative numbers intact; they stays negative. Logical shifts fill the space from the top with zeroes no matter what previous sign bit was. When a logical shift is applied to a negative number, that number instantly becomes positive. It’s one of those things many developers fail to consider when troubleshooting signed integer problems. The calculator makes the distinction clear here for you to see how a negative flag can suddenly become a large positive.

There’s no need to memorize all powers of two. It’s helpful to know that 1 shifted left ten places gives you one thousand twenty four. This explains why a kilobyte is defined as it is in binary. It also shows how graphics cards squeeze multiple color channels into a single integer. To get just the red component out of an RGB value, for example, you might shift it right by sixteen spots to reposition its bits at the least significant end. You’ll see these multipliers in the tables on page, where you won’t have to figure it out in your head every time.

While most bit manipulation is hidden away in high-level languages it’s still relevant. Cryptography, game engines, embedded systems use shifts because they’re fast and precise. Knowing how to preserve signs and handle overflows of bits will save you hours of debugging down the road. This tool helps connect your code to reality of the underlying hardware. It makes numbers something tangible, an arrangement of switches that can be physically manipulated instead of an abstraction.

Pay attention to the width of your registers. Something that works perfectly in 32 bit might not work at all in 8. Pick your operations wisely, particularly if you are combining both signed and unsigned numbers. Erasing the sign and maintaining it is often what makes something right or wrong.

After you get a feel for how those bits is moving around, you’ll naturaly be thinking in binary terms much more easy. It’s always going back to just ones and zeros moving around the system.

Bit Shift Calculator: Left & Right Shift, Logical vs Arithmetic