Parity bit


Check Bit, which is a bit that can detect errors.

How


  • Examing the Least significant bit of the whole communication string
  • Applied in an 8-bit communication system 7 + 1(parity)

the sum of every bit should be 0

Examples


take 25 (0b11001) as an example

0 1 2 3 4 5 6 7
0 0 1 1 0 0 1 1

The parity bit is the 7th bit, since the sum of every bit in 25 (0b11001) is 1; therefore the value of parity bit is


take 30 (0b11110) as an example

0 1 2 3 4 5 6 7
0 0 1 1 1 1 0 0

The parity bit is the 7th bit, since the sum of every bit in 30 (0b11110) is 0; therefore the value of parity bit is

Error Detection


If single bit flip occurs, the sum of the bits will not be 0. That is, you can simply sum every bits to check whether an error appears.

a simple python code to check 30 (0b11110) is listed below

>>> from functools import reduce
>>> message = "00111100" # e = 0b0
>>> reduce(lambda a, b: int(a) ^ int(b), message) == 0
True
>>> message = "00110100" # e = 0b1000
>>> reduce(lambda a, b: int(a) ^ int(b), message) == 0
False

Problems


The bigest problem of parity bit is that you can't identify the error if the hamming distance is even. (We will say that this erorr detection only works while , even though it can detect since we are looking for the shortest).

Check m = 30 (0b11110) again but with with error e 11000000 => m + e = (0b1111110)

>>> from functools import reduce
>>> message = "11111100" # Message recieved in Binary
>>> reduce(lambda a, b: int(a) ^ int(b), message) == 0
True
  • The result is True which means no errors however,

This is called a collision, which means two different system have the same parity code

See also