Randomly

Bitwise calculator

Run AND, OR, XOR, NAND, NOR, XNOR, NOT or a bit shift on integers of almost any size. Results show in decimal, binary and hex side by side.

Result

AND

Bitwise operators act on each binary digit independently: AND keeps bits set in both operands, OR in either, XOR in exactly one. Shifts move bits left or right (operand B is the shift amount). NOT inverts every bit of operand A.

12 AND 10 = 8
Operations
9
Bases
Dec · hex · bin

Related tools

This bitwise calculator applies one of nine operations to the integers you type: AND, OR, XOR, NAND, NOR, XNOR, NOT, left shift and right shift. Enter operands in plain decimal or with a 0x, 0o or 0b prefix. The result shows in decimal, binary and hex together, and you can click any of them to copy it. The math uses BigInt, so operands up to 8,192 bits work, and it all runs in your browser.

How to use the bitwise calculator

  1. Type operand A, for example 12, 0xFF, 0o17 or 0b1010.
  2. Pick an operation from the dropdown.
  3. Type operand B. For shifts, B is how many places to move (0 to 4096). NOT only uses A, so the B field disappears.
  4. Read the result in decimal, binary and hex, and click a value to copy it.

Quick guide to bitwise operations

AND keeps a bit only when both inputs have it, which is how masks work. OR keeps a bit when either input has it, the usual way to combine flags. XOR keeps the bits that differ, so XOR-ing with the same value twice gets you back where you started. Left shift by n multiplies by 2^n; right shift divides by 2^n and rounds down. NAND, NOR and XNOR are AND, OR and XOR with every bit flipped.

One thing trips people up: there's no fixed width here, no 8, 16 or 32 bits. NOT follows two's-complement rules on a number of unlimited width, so NOT 12 gives -13, not 243. For an 8-bit NOT, XOR with 0xFF instead (12 XOR 255 = 243).

Frequently asked questions

What is a bitwise calculator used for?

Checking flag and permission masks, working out subnet masks, debugging low-level code, and computer science homework on how bits behave.

Can I enter hex values into the bitwise calculator?

Yes. Prefix hex with 0x (0xFF), octal with 0o (0o17) and binary with 0b (0b1010). Anything without a prefix is read as decimal, and a leading minus makes it negative.

Why does NOT give me a negative number?

Because the calculator doesn't assume a bit width. Here NOT x always equals -(x + 1). For a fixed width, XOR with a mask of all ones, such as 0xFF for 8 bits or 0xFFFFFFFF for 32.

What is the difference between AND and NAND?

NAND is AND followed by NOT. Every bit AND sets to 1, NAND sets to 0, and the other way round. Because of the unlimited width, NAND of two non-negative numbers comes out negative.

Built and maintained by Bipul Kumar. Found a wrong number or a broken result? Tell me and I'll fix it.