Understanding the parity bit calculator — concept and principle
A parity bit is the simplest form of error detection: one extra bit that makes the number of 1s even or odd. This calculator computes the parity bit to add to your data, shows the bits with the parity bit appended and checks a received word whose last bit is already the parity bit.
How it is calculated
Count the 1s in the data bits.
Even parity: parity bit = 1 if the count is odd, else 0
Odd parity: parity bit = 0 if the count is odd, else 1
Equivalently, parity bit = (count mod 2) XOR type (0 = even, 1 = odd)
Check: a received word passes if its total count of 1s has the chosen parity.
The principle
Flipping any single bit changes the number of 1s by one, which changes whether the count is even or odd. So if sender and receiver agree on the parity, a single flipped bit makes the received word fail the check. The method is cheap, one extra bit and a simple XOR, which is why it is used in serial links and some memory. Its weakness is that two flipped bits restore the original parity and pass unnoticed, and parity cannot say which bit was wrong.
Worked example
Default inputs: bits 1011001, even parity.
- Count the 1s: 1 + 0 + 1 + 1 + 0 + 0 + 1 = 4.
- 4 is already even, so the parity bit = 0.
- Bits with the parity bit = 1011 0010.
- Reading 1011001 itself as a received word (last bit 1 as parity): it has 4 ones, which is even, so parity correct.
How to read the result
Send the data followed by the parity bit. The receiver counts the 1s; a parity error means an odd number of bits changed, most often one. If errors are likely to come in pairs or bursts, use stronger codes such as CRC or Hamming codes. Even and odd parity detect errors equally well; the choice is a convention both ends must share.
Common mistakes
- Using even parity at one end and odd at the other.
- Assuming a passed check guarantees no errors; two flips go unnoticed.
- Forgetting to include the parity bit itself when checking.
- Expecting parity to correct errors; it only detects them.
Frequently asked questions
What is the difference between even and odd parity?
Even parity makes the total number of 1s even; odd parity makes it odd.
Can parity correct errors?
No. It only shows that an error occurred, not where.
Why does a 2-bit error go undetected?
Two flips change the count by 0 or 2, keeping its parity.
Where is parity used?
In UART serial communication, some memory systems and simple data checks.
Sources: R. W. Hamming, "Error Detecting and Error Correcting Codes", The Bell System Technical Journal 29(2): 147–160, 1950, §2 (single error detecting codes)