See both operands and the result stacked in aligned bit columns for nine operations, at 8, 16, 32 or 64 bits with exact arithmetic.
Decimal, or with a 0x, 0b or 0o prefix.
10 signed · 10 unsigned · 0x0A
A bit is 1 only where both inputs have 1.
| Row | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| A | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
| B | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| Result | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
A bit is 1 only where both inputs have 1.
Masking: `flags & READ` keeps only the bits you asked about, and `x & 0xFF` keeps the low byte.
Nothing surprising about this one — no bits lost, no sign extension and no out-of-range shift.
Bitwise Operation Visualizer runs entirely on your device — every bit is computed in the page with exact big-integer arithmetic.
You’re on the Free plan. Compare plans
The aligned bit columns are the whole point. An AND is obvious once you can see the two operands stacked with the result underneath, and nearly opaque as two decimal numbers and a third. The columns are numbered from the low bit, the way `1 << n` numbers them, so the position in the table is the position in your code.
Nine operations, including the two that are not operators in most languages. Rotations preserve every bit — nothing falls off the end — which is why hashing and ciphers are built from them, and why SHA-256 is a stack of right rotations. Most languages have no operator for one, so it is written `(x << n) | (x >>> (width - n))`.
The difference between the two right shifts is shown where it is visible. Arithmetic shift copies the sign bit into the top; logical shift fills with zeros. On positive values they are identical, which is why picking the wrong one hides until it breaks something — so when the sign bit is set, the tool says which is which and what each gives.
Shifting at or past the width is called out rather than quietly handled. In C it is undefined behaviour; JavaScript and Java use only the low bits of the distance; nothing portable happens. Saying which is more useful than refusing the input or silently picking one.
Everything is computed with exact big-integer arithmetic at the chosen width. JavaScript's own operators would coerce to signed 32-bit first, so a 64-bit row computed with them would be wrong — which is partly what this tool is here to explain.
Arithmetic shift copies the sign bit into the top; logical shift fills with zeros. They give the same answer on positive values and very different answers on negative ones, which is why choosing wrong stays hidden until it breaks. Try −8 with each.
Because an arithmetic shift fills from the left with copies of the sign bit, and it rounds toward negative infinity. All-ones shifted right is still all-ones, so it never reaches zero.
`flags & ~FLAG`, which is the AND NOT operation here. Writing `flags - FLAG` works until the flag was already off, and then it corrupts the other bits — a bug that only shows up on the second call.
Nothing portable, and the tool says so. In C it is undefined behaviour; JavaScript and Java use only the low bits of the distance. Relying on either is relying on one compiler's choice.