Bitwise Calculator
AND, OR, XOR, NOT, NAND, NOR, logical and arithmetic shifts, rotates at 8, 16, 32 or 64 bits — binary, hex, octal, unsigned and two’s-complement decimal.
Every operation in one table with binary (nibble-grouped), hex, octal, unsigned and signed values, both operands bit by bit with their popcount, and modular add / subtract at the chosen width.
Example: 12 AND 10 = 8, OR 14, XOR 6; NOT 12 at 8 bits = 243 (−13 signed); −1 at 16 bits is 0xFFFF — arithmetic shift right keeps −1, logical shift gives 32767; 0xFFFFFFFFFFFFFFFF stays exact at 64 bits.
Fixed width,
two's complement.
How values are read and wrapped, what each operation does, and the shift conventions.
Values and width
Operands are read in decimal, hex (0x), octal (0o) or binary (0b), with underscores or spaces allowed as separators, then reduced modulo 2ⁿ to the chosen width — so −1 at 16 bits is 0xFFFF and 300 at 8 bits wraps to 44, and the page says when that happened. Every result is shown unsigned and as a two's-complement signed number (values from 2ⁿ⁻¹ up read as negative). Arithmetic is on arbitrary-precision integers, so 64-bit values are exact.
Operations
AND, OR, XOR and their negations NAND, NOR, XNOR combine a and b bit by bit; NOT flips every bit of a within the width; negate is −a mod 2ⁿ, which equals NOT a + 1. Add and subtract are modulo 2ⁿ, the way a CPU register behaves. Popcount is the number of set bits.
Shifts and rotates
Left shift drops the bits that leave the width. Logical right shift fills with zeros (JavaScript >>>); arithmetic right shift copies the sign bit (>> on a signed value), so −1 stays −1. Rotates move the bits that fall off one end back in at the other. A shift by the full width or more is undefined in C and JavaScript and is refused here. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.
SOURCES
- Two's complement arithmetic modulo 2ⁿ: −x = ~x + 1; logical shift fills with 0, arithmetic shift copies the sign bit; rotates wrap; all values as arbitrary-precision integers masked to the width
Last reviewed 22 September 2026. How results are checked: How we verify.