Hex Bitwise Calculator

This is a hex bitwise calculator. Enter A and B as hex, decimal, or binary, pick AND / OR / XOR / NAND / NOR / XNOR / NOT / SHL / SHR / ASR, and see hex, decimal, and binary together. 0xB7 AND 0x0F at 8 bits is 0x07.

Click a bit on A or B to flip it.

A

B

Result

Click a value to copy it

AND, OR, XOR, NAND, NOR, XNOR, NOT for the same A and B

Truth table (click a row to load A and B)

ABANDORXORNANDNORXNORNOT A
000001111
010111001
100111000
111100010

Examples — click a swatch

This is a hex bitwise calculator

This page runs bitwise AND, OR, XOR, NAND, NOR, XNOR, NOT, SHL, SHR, and ASR on two integers and shows the same result as hex, unsigned decimal, signed decimal, and grouped binary. Width can be Auto, 8, 16, 32, or 64 bits. 0xB7 AND 0x0F at 8 bits is 0x07. 0xCC AND 0xAA is 0x88. 0x2E AND 0x4A is 0x0A. AND, OR, XOR, NAND, NOR, XNOR, NOT, SHL, SHR, ASR, HEX stay untranslated.

How to use

  1. Set A and B. Each field has its own format: Hex, Decimal, or Binary. 0x and 0b prefixes are optional.
  2. Pick the operator and the bit width. Auto fits 8/16/32/64 to the larger operand. Unsigned vs signed only changes how decimal is read and shown; the bits stay two’s complement.
  3. Click a bit on the A or B grid to flip it. The result row is not clickable. Red rings mark bits that differ from A.
  4. Chips copy hex / binary / decimal. The summary table lists AND through NOT for the same inputs; click a row to switch the operator. The truth table loads 0/1 into A and B at 8 bits.
  5. Show example is 0xB7 AND 0x0F at 8 bits → 0x07. Extra chips cover 0xCC AND 0xAA, 0x2E AND 0x4A, XOR, NOT 0xCC, and 0x80 SHR 4.

Notes

Values are masked to the width. A shift amount ≥ width is treated as 0. Logical SHR fills with zeros; ASR copies the sign bit: 0x80 SHR 4 at 8 bits is 0x08, ASR is 0xF8. NAND is NOT(AND), NOR is NOT(OR), XNOR is NOT(XOR). This is not the hex compare Hamming tool and not a walk-through of two’s complement.

Where to use it

  • Flag masks and register dumps (keep these bits, set these bits, toggle these bits).
  • Checking a nibble, a permission bit, or a packed field shown as hex in a log.

Questions

Why does NOT change when I pick 64 bits?

NOT flips every bit in the width, so leading zeros become ones. NOT 0x0F is 0xF0 at 8 bits and 0xFFFFFFF0 at 32 bits.

What is the difference between SHR and ASR?

SHR is logical: new high bits are 0. ASR is arithmetic: new high bits copy the old sign bit so a negative pattern stays negative.

Can I type decimal or binary instead of hex?

Yes. Switch the format under A or B. The bit grid and the three result fields stay in sync.