%3C/text%3E%3C/svg%3E">
💻
💻 Tech & IT

Bitwise Calculator (AND, OR, XOR, NOT, shifts)

Results update as you type.

Your numbers

Understanding the bitwise calculator — concept and principle

Bitwise operators work on the individual bits of integers rather than on their numeric value. They are used for flags and permission masks, packing several small values into one word, hashing, graphics, network masks and fast multiplication or division by powers of two. This calculator applies AND, OR, XOR, NOT and the three shifts to two decimal inputs using 32-bit two's-complement integers, the same rules as JavaScript, Java and C on common platforms.

AND, OR, XOR and shifts of 12 and 101100 AND 1010 = 1000 (8), OR = 1110 (14), XOR = 0110 (6); 12 shifted left 2 is 48, right 2 is 3.Bit by bit, column by columnA1100= 12B1010= 10AND1000= 8OR1110= 14XOR0110= 612 << 2 = 110000 = 48× 412 >> 2 = 11 = 3÷ 4
AND keeps bits set in both, OR in either, XOR where they differ; each shift doubles or halves.

How it is calculated

The principle

A binary number is a sum of powers of two, and each bit is independent of the others in AND, OR and XOR, so these operations act like 32 parallel logic gates. Shifting moves every bit to the next power of two, which is why it scales by 2. Two's complement represents −x as NOT x + 1, so the top bit acts as the sign and ordinary binary addition works for negative numbers too. That same rule gives NOT A = −A − 1.

Worked example

  1. Inputs: A = 12 (1100), B = 10 (1010), shift = 2.
  2. AND: 1100 & 1010 = 1000 = 8. OR: 1110 = 14. XOR: 0110 = 6.
  3. NOT 12: all 32 bits flipped gives 11111111111111111111111111110011, which is −13 (= −12 − 1).
  4. 12 << 2 = 110000 = 48 (12 × 4).
  5. 12 >> 2 = 11 = 3, and because 12 is positive, 12 >>> 2 is also 3.

How to read the result

To test a flag, check whether value AND mask is non-zero; to set it use OR; to clear it use AND with NOT mask; to toggle it use XOR. The arithmetic and logical right shifts only differ for negative inputs: −8 >> 1 is −4, while −8 >>> 1 is 2147483644.

Common mistakes

Keep in mind: Results follow 32-bit JavaScript semantics. Other languages differ at the edges: in C, shifting a negative value or overflowing a signed shift can be undefined or implementation-defined, and Python integers have no fixed width.

Frequently asked questions

Why is NOT 12 negative?

Flipping all 32 bits sets the sign bit, and in two's complement the result is −12 − 1 = −13.

Is A << 1 always the same as A × 2?

Only while the result stays inside the 32-bit range; otherwise high bits are lost.

What is XOR used for?

Toggling bits, parity and checksums, and finding where two bit patterns differ.

Sources: Ecma International, ECMA-262 ECMAScript Language Specification (bitwise and shift operators) · Henry S. Warren Jr., Hacker's Delight, 2nd ed., Addison-Wesley, 2012

Checked 8 Nov 2026. Standard formulas and RFC/IEEE definitions, computed locally in your browser — nothing you type is sent anywhere.

💻 All tech & IT tools →🌍 Calculators by country →