Bitwise Calculator
Run AND, OR, XOR, NOT, left shift or right shift on two integers and see the exact decimal, hexadecimal and binary result — using arbitrary-precision BigInt math, with no 32-bit truncation.
Input
For Left Shift / Right Shift, this is the shift amount (0–1024). Not used for NOT.
Output
| Property | Value |
|---|---|
| No data yet | |
Guides
A bitwise calculator applies logic operations directly to the binary representation of numbers, bit by bit, rather than treating them as ordinary decimal values. This tool runs AND, OR, XOR, NOT, left shift and right shift on two integers and shows the result as decimal, hexadecimal, and binary — useful for debugging bit flags, permission masks, network subnets, low-level protocol fields, or learning how binary logic works.
How to use it
Enter Number A (decimal, e.g. 42, or hex, e.g. 0x2A — a leading - is allowed), choose an Operation, and enter Number B — the second operand for AND/OR/XOR, or the shift amount for Left/Right Shift (unused for NOT, which works on Number A alone). The result updates automatically as decimal, hexadecimal, and binary.
The operations
| A | B | AND | OR | XOR |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
- AND (
&) — a bit is1only if both input bits are1. - OR (
\|) — a bit is1if at least one input bit is1. - XOR (
^) — a bit is1if the input bits differ. - NOT (
~) — flips every bit of a single number (unary — Number B is ignored). For an integern,~nequals-(n + 1); e.g.~5is-6. - Left Shift (
<<) — shifts A's bits left by B positions, filling with zeros on the right. Equivalent toA × 2^B. - Right Shift (
>>) — shifts A's bits right by B positions, discarding the low bits. Equivalent to integer division by2^B, rounding toward negative infinity (works correctly for negative numbers too).
Example
12 AND 10: 12 is 1100 in binary, 10 is 1010. Comparing bit by bit: 1100 & 1010 = 1000, which is 8 in decimal. The same two numbers with OR give 1110 (14), and with XOR give 0110 (6).
Why BigInt instead of plain numbers
Many bitwise calculators coerce numbers to 32-bit signed integers before running the operation, because that's what JavaScript's native &, |, ^, ~, <<, and >> do on ordinary Number values — anything larger than about 2.1 billion (2^31) gets silently truncated to the wrong value. This tool uses JavaScript's BigInt type instead, whose bitwise operators have no fixed width, so results stay exact no matter how large the operands are.
FAQ
Why does NOT produce a negative number? Integers are conceptually an infinite run of leading 1s (negative) or 0s (positive) in two's-complement form, so flipping every bit of a non-negative number always produces a negative one. Standard two's-complement behavior, not a bug.
Is there an unsigned right shift (>>>)? No. Unsigned shift only makes sense for a fixed bit width (it zero-fills instead of sign-extending), and this tool's numbers have no fixed width — that's exactly what lets it handle arbitrarily large values correctly.
What's the largest shift amount allowed? Shift amounts are capped at 1024 to keep every result instantly computable; a shift that large already produces a result over 1000 bits long.
Can I use hexadecimal input? Yes — prefix either number with 0x (e.g. 0xFF). Output is always shown in decimal, hex, and binary regardless of which format you typed.
Privacy
All calculations run locally in your browser using standard JavaScript — nothing you enter is uploaded or stored.