A parity bit is actually a bit whose value is either 0 or 1, while it is added to the block of data to perform error detection functions. It provides data either an odd parity or an even parity, which is used to validate the integrity of the data.
Parity bits are mostly used in data transmission to see if the data is getting corrupted somewhere during this transfer process.
For example, the data for each 7 bits includes a parity bit (which consists of 8 bits in total, or one byte). If the data transmission protocol is set to an odd parity, then every data packet will have an odd parity. At the same time if it is set in even, then every packet will definitely have an even parity. If a packet was received with the wrong parity, then an error will occur and the data will need to be retransmit again.
The parity bit of each data packet is computed before the transmission of data. Let us understand below how parity bit is computed using both odd and even parity settings.
|Odd Parity||Even Parity|
|Initial value: 1010101 (four 1s)||Initial value: 1010101 (four 1s)|
|Parity bit added: 1||Parity bit added: 0|
|Transmitted value: 10101011||Transmitted value: 10101010|
|Result: Odd parity (five 1s)||Result: Even parity (four 1s)|
The value of the Parity Bit depends on the initial parity of the data. For example, binary value of 10000000 has an odd parity. In such a case, a 0 will be added so that the parity can be kept odd and a 1 will be added to it to generate the value of an even parity.
By the way, parity checking is a useful method for validating data, while it is not a foolproof method. For example, values 1010 and 1001 have the same parity. So if value 1010 is transmit and 1001 is received, then no error is detected.
This means that parity checks are not 100% reliable when the data is being validated. Anyway, it will be very less that a bit more incorrect than a bit in the data of a small packet. Until only one bit is changed, then the error is seen. Therefore, parity checks are quite reliable when small packet sizes are used.