Skip to content
BetterDL

Parity

Also called: parity function, bit parity

Whether a group of bits contains an odd or an even number of 1s. An XOR of all the bits gives 1 when the count is odd and 0 when it is even.

The parity of a group of bits says whether the count of 1s in it is odd or even. The bits 1101 hold three 1s, so their parity is odd. The bits 1001 hold two, so their parity is even. Zero 1s counts as even.

The gate that computes parity is XOR. A multi-input XOR outputs 1 exactly when an odd number of its inputs are 1:

  • is 1 for one or three 1s.
  • Inverting it, , gives 1 for zero or two 1s.

These two functions are the odd function and the even function. Each is 1 in exactly half the rows of its truth table.

You can find parity two ways, and they always agree:

  1. Count the 1s and check odd or even. Fastest with many bits.
  2. Chain XORs one bit at a time. Order doesn't matter, because XOR is commutative and associative.

The big application is error detection. A sender adds a parity bit so the total number of 1s has a known parity. If noise flips one bit on the way, the parity changes and the receiver notices. Parity can't tell which bit flipped, and it misses two flips, but it costs only one extra bit and a few XOR gates.

0000
0011
0101
0110
1001
1010
1100
1111

Worked example

Example

Parity of a byte

Find the parity of 10110110, and what an 8-input XOR outputs for it.

  1. 1.

    Count the 1s: positions 1, 3, 4, 6 and 7 from the left. That is five 1s.

  2. 2.

    Five is odd, so the parity is odd.

  3. 3.

    An 8-input XOR outputs 1 for an odd count, so it gives 1.

  4. 4.

    Check by XORing in pairs: 10 → 1, 11 → 0, 01 → 1, 10 → 1. Then 1⊕0 = 1 and 1⊕1 = 0. Finally 1⊕0 = 1.

Common mistakes

  • Counting 0s instead of 1s. Parity is about the number of 1s.

  • Forgetting that zero 1s is even, so 0000 has even parity.

  • Assuming parity catches every error. Two flipped bits leave the parity unchanged.

Practice Parity

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Parity is taught in Logic Gates and Combinational Logic.