Parity bit

Updated: 11/12/2023 by Computer Hope
Parity bit

A parity bit, also known as a check bit, is a single bit that can be appended to a binary string. It is set to either 1 or 0 to make the total number of 1-bits either even ("even parity") or odd ("odd parity"). More specifically, in even parity, if the data contains an odd number of ones, the parity bit is set to 1 to make the total number of ones even. In odd parity, it's the other way around; the parity bit is set to 1 if the data has an even number of ones (making the total number odd).

The purpose of a parity bit is to provide a simple way to check for errors later. When data is stored or transferred electronically, it's not uncommon for bits to "flip" — change from a 1 to a 0, or vice versa. Parity checks can detect these errors. If there's a mismatch in the transmission and the number of received ones doesn't match the expected parity, an error is generated. For example, to check a binary sequence with even parity, the total number of ones can be counted. If the number of ones is not even, an error is likely to have occurred.

The inherent weakness in this type of error checking is that it can only detect an odd number of errors in the sequence. If an even number of bits are flipped, a parity check will not catch it.

Example parity checking process

  1. The data 10101 is given the even parity bit of 1, resulting in the bit sequence 101011.
  2. This data is transferred to another computer. In transit, the data is corrupted, and the computer receives the incorrect data 100011.
  3. The receiving computer computes the parity: 1+0+0+0+1+1 = 3. It then performs 3 modulo 2 (the remainder of 3 divided by 2), expecting the result 0 which would indicate that the number is even.
  4. Instead, it receives the result 3 modulo 2 = 1, indicating that the number is odd. Because it is looking for numbers with even parity, it asks the original computer to send the data again.
  5. This time, the data comes through with no errors: 101011. The receiving computer calculates 1+0+1+0+1+1 = 4.
  6. 4 modulo 2 = 0, indicating even parity. The parity bit is stripped from the end of the sequence, and the data 10101 is accepted.

Check bits, Hardware terms, Mark parity, Parity check, Space parity