A parity bit is a bit that is added to a code to detect error/errors during its transmission. So, the codes with parity bits are called as error detecting codes.
There are two types of parity bit - even parity bit and odd parity bit.
In even parity, after adding the parity bit, the number of 1s in the code is even and in odd parity, after adding the parity bit, the number of 1s in the code is odd.
7 bits of data (number of 1s) | 8 bits including parity | |
---|---|---|
even | odd | |
0000000 (0) | 00000000 | 10000000 |
1010001 (3) | 11010001 | 01010001 |
1101001 (4) | 01101001 | 11101001 |
1111111 (7) | 11111111 | 0111111 |
This is an example of addition of parity bit in ASCII code
Even parity is a special case of a cyclic redundancy check (CRC), where the 1-bit CRC is generated by the polynomial x+1.
If the parity bit is present but not used, it may be referred to as mark parity (when the parity bit is always 1) or space parity (the bit is always 0).
ERROR DETECTION USING PARITY BIT
in the process, generally an even parity is created at the transmitting end.the information is sent and the parity of the code is checked at the receiving end. if the parity has changed to odd parity, then, it means either 1 or 3 or an odd number of bits in the code have changed their values during code transmission. but, parity bit can only detect error if odd number of bits have changed their values. if an even number of bits have changed their values, then the parity of the code remains the same. and also it cannot correct that error.
example :
transmission end - 10001110
receiver end - 10011110
here, in the beginning there is even parity but at receiver end the parity has changed to odd. so, the error has been detected