InfyCalculator
💻

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

Apply bitwise AND, OR, XOR, NAND, NOR, XNOR, NOT and left/right shifts to decimal, hex or binary numbers in 8, 16 or 32 bits, with every operand and the result shown in binary, hex and decimal.

A
Operation
B (or shift amount)
Input base
Word size
Loading calculator…

How it works

AND: 1 only where both bits are 1 · OR: 1 where either is 1 · XOR: 1 where the bits differ · NOT: invert every bit (within the word size) · NAND / NOR / XNOR = NOT of AND / OR / XOR · A << n = A × 2ⁿ (bits shifted out are lost) · A >> n (logical) = ⌊A ÷ 2ⁿ⌋ with zeros shifted in

Bitwise operators work on each bit position independently, which is how programmers set, clear, toggle and test flags, build masks, pack fields into registers and compute checksums. The result depends on the word size: NOT 12 is 243 in 8 bits but 65,523 in 16 bits, because all the leading zeros flip too. Negative inputs are accepted and stored as two’s complement; the result is shown both unsigned and as a signed value.

Worked example

12 AND 10 in 8 bits: 12 = 0000 1100 and 10 = 0000 1010; only bit 3 is 1 in both, so the result is 0000 1000 = 8 (0x08). With the same inputs OR gives 14 (0000 1110) and XOR gives 6 (0000 0110).

Sources: Bitwise operation — Wikipedia · ISO/IEC 9899 (C) bitwise operators — cppreference

Frequently asked questions

What is the difference between AND and OR in bit operations?

AND keeps a bit only if it is set in both numbers, so it is used to clear bits or test them with a mask (x AND 0x0F keeps the low nibble). OR sets a bit if it is set in either number, so it is used to switch flags on (x OR 0x80 sets the top bit).

What is XOR used for?

Toggling bits (x XOR mask flips exactly the masked bits), comparing values (A XOR B is zero only when A = B), parity and checksums, simple ciphers and swapping two variables without a temporary.

Why does NOT give a large number instead of a negative one?

NOT flips every bit of the word, including leading zeros: NOT 12 = 1111 0011 = 243 unsigned in 8 bits. Read as a signed two’s complement byte the same bits are −13, which is what languages like C and JavaScript (~12 = −13) print.

Is a left shift the same as multiplying by 2?

Yes, each left shift doubles the value as long as no 1 bits fall off the top of the word; a logical right shift halves it, rounding down. Arithmetic right shifts on signed values copy the sign bit instead — this calculator uses logical (zero-fill) shifts.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.