Left Shift Example
Shifting 13 left by 2 positions returns 52 in an 8-bit word. Each active bit moves two positions toward the most significant bit (MSB), and two zeros enter from the right.
00001101 << 2 → 00110100 13 << 2 = 52
This bit shift calculator moves an integer left or right and shows the result in binary, decimal, and hexadecimal. Select Auto, 8-bit, 16-bit, 32-bit, or 64-bit width, then compare left shift, logical zero-fill right shift, and signed arithmetic right shift. The visualization marks moved bits, zero fill, sign fill, and discarded bits for bit manipulation, packed fields, and low-level programming.
46 Hex0x2E To use the bit shift calculator, enter one value, choose its number system, set the width and direction, then enter the shift count. The result and binary movement diagram update immediately.
Shift Setup Walkthrough
0010 11100010 1110[ 0 0 1 0 1 1 1 0 ]46 << 10101 1100Naming note: Left Shift has no separate logical and arithmetic variants in this tool because both move bits left and insert zeros on the right. Right shift needs two modes: Logical Right inserts zeros on the left, while Arithmetic Right copies the selected-width sign bit.
Mode note: arithmetic right shift interprets the selected-width pattern as a signed two's-complement integer. Circular bit shift, rotate through carry, and carry flag simulation remain separate operations and are not calculator modes.
The calculator supports three input bases, five width choices, and three shift modes. The support table separates available functions from related operations that are outside the current tool.
Capability Explorer
| Feature | Support | Behavior |
|---|---|---|
| Binary, decimal, and hexadecimal | Supported | Accepts one base and displays all three output bases. |
| Bit width | Supported | Auto, 8-bit, 16-bit, 32-bit, and 64-bit. |
| Left shift | Supported | Moves bits left and fills new right positions with zero. |
| Logical right shift | Supported | Moves bits right and fills new left positions with zero. |
| Visual calculation steps | Supported | Marks moved, filled, and discarded bit positions. |
| Signed arithmetic right shift | Supported | Copies the selected-width sign bit into new left positions. |
| Circular rotation, masking, and carry bit | Not included | Use a rotation or bitmask tool for these separate operations. |
These four bit shift examples show left shift, logical right shift, signed arithmetic right shift, and hexadecimal conversion.
Example Switcher
00001101<< 2001101005200101100>> 2000010111111110000>> 211111100-4 signed0x3C<< 10x78120Shifting 13 left by 2 positions returns 52 in an 8-bit word. Each active bit moves two positions toward the most significant bit (MSB), and two zeros enter from the right.
00001101 << 2 → 00110100 13 << 2 = 52
Shifting 44 right by 2 positions returns 11. Two low bits leave the least significant bit (LSB) side, and two zeros fill the left side.
00101100 >> 2 → 00001011 44 >> 2 = 11
An 8-bit arithmetic right shift of -16 by 2 positions returns -4. The signed value 11110000 keeps a leading 1 through sign extension: 11110000 → 11111100. Select Arithmetic Right in the calculator to reproduce this result.
Shifting 0x3C left by 1 position returns 0x78. Hexadecimal conversion represents the same movement as 00111100 → 01111000.
0x3C << 1 = 0x78 Bit shifting is a bitwise operation that moves the binary digits of a fixed-width integer left or right by a specified shift amount. A logical shift discards bits that cross the width boundary and inserts zeros in the newly opened positions. The operation changes bit position without changing bit order.
Live Bit Motion
The binary number system assigns a place value of 2n to each bit. Moving a 1 toward the MSB increases its place value, while moving a 1 toward the LSB decreases its place value. CPU architecture and assembly language expose shift instructions for integer arithmetic, field extraction, flag registers, and other bit manipulation tasks.
Zero Fill vs Sign Fill
00101110 → 01011100010110000 → 0101100011110000 → 11111000A left shift moves every included bit toward the most significant side and fills the right side with zeros. Shifting left multiplies an unsigned integer by 2n when the selected width does not discard an active high bit.
A logical right shift moves every included bit toward the least significant side and fills the left side with zeros. The right shift operation discards low bits, so an unsigned result matches floor division rather than fractional division.
An arithmetic right shift preserves a signed negative value by copying the sign bit into each new high position. This sign-fill behavior differs from the zero-fill logical shift operation and uses the selected width to locate the sign bit.
Formula Calculator
The left shift formula is x << n = x × 2n when no significant bit overflows the selected width. For example, 7 << 3 = 7 × 8 = 56. A fixed-width result applies the width mask after the bitwise operation is executed.
An unsigned logical right shift follows x >> n = floor(x / 2n). Shifting right divides by a power of two and discards the remainder stored in low bits. Signed negative values require the language's arithmetic or logical shift rules.
Two's complement lets one fixed-width bit pattern represent a signed integer or an unsigned integer. The 8-bit pattern 11110000 equals 240 unsigned and -16 signed. Sign extension applies only when a right shift uses arithmetic signed behavior.
Bit width sets the overflow boundary and the number of visible binary positions. An 8-bit shift keeps 8 positions, while 32-bit and 64-bit shifts keep larger words. Bits moved beyond the boundary are truncated, and this bitwise overflow detection tool marks those bits in red.
Bit Field Positioner
Bit shifts place a 1 at a selected flag position before a bitmask operation sets, clears, or tests that flag. Permissions and feature flags often use expressions such as 1 << n.
Shifts position integer fields inside a packed value and move extracted fields back to the least significant position. A mask normally follows a right shift to remove unrelated bits.
Left and right shifts express multiplication and integer division by powers of two. Modern compilers perform performance optimization, so shifts should express bit-level intent rather than assume faster execution.
Embedded systems, graphics code, and network protocols use shifts to position register fields, RGB channels, packet flags, and numeric header values. The same patterns appear in low-level programming and binary file formats.
Language Semantics
unsigned int y = x >> n;Width follows the promoted integer type.const y = x >> n;Bitwise operands convert to signed 32-bit integers.y = x >> nIntegers use arbitrary precision and negative shifts preserve the sign.The C programming language and C++ use x << n for left shift and x >> n for right shift. Unsigned right shift uses zero fill. Signed right shift and signed overflow depend on the language standard, integer type, and implementation, so convert to an appropriate unsigned type when the required bit pattern must be explicit.
A shift count must be nonnegative and smaller than the width of the promoted left operand. C and C++ code has undefined behavior for invalid or excessive shift counts. Java bitwise operators define fixed integer widths, JavaScript bitwise operators convert values to 32-bit integers, and Python bitwise operators use arbitrary-precision integers, so code can differ from a fixed-width calculator.
Troubleshooting Selector
Select the width used by the target data type. An 8-bit result can discard a high bit that remains present in a 32-bit result.
Confirm whether the binary pattern represents a signed integer or an unsigned integer. The same high bit changes the decimal interpretation under two's complement.
Expect truncation when low bits contain a remainder. For example, 7 >> 1 returns 3, not 3.5.
Check the red discarded-bit markers before using the result. Left shift multiplication fails when integer overflow removes an active high bit.
Use a rotation operation when shifted-out bits must return on the opposite side. A normal shift discards those bits and does not update a carry bit.
Keep the shift count below the operand width when matching C or C++. This calculator clamps the displayed movement to the selected width, while programming languages define their own excessive-count behavior.
Direct answers about logical shifts, arithmetic shifts, overflow, bit width, and hexadecimal input.