GoalWork out the parity bit for seven data bits with even and odd parity, and check whether a received byte passes.
New words
parity bit · an extra bit added to the data so that the number of 1s follows an agreed ruleeven parity · the rule that the total number of 1s in the byte must be evenodd parity · the rule that the total number of 1s in the byte must be oddparity check · an error-detection method that counts the 1s in a received byte and compares the count with the rule
Explanation
Bits can change on their way along a cable or through the air, for example because of interference, crosstalk between cables or a power surge. A parity check can notice some of these changes. The sender adds one extra bit, the parity bit, to seven data bits, so that the 8 bits follow an agreed rule: with even parity the number of 1s must be even, and with odd parity it must be odd. To find the parity bit, count the 1s in the data bits. With even parity the bit is 1 if the count is odd and 0 if it is even, and with odd parity it is the other way round. Both devices must agree on even or odd before sending, for example during a handshake. Another method you met earlier is the echo check: the data is sent back and compared with what was sent, which detects an error but does not fix it. In this course the parity bit is written first, on the left. The receiver counts the 1s in all 8 bits, and if the count breaks the rule, the byte fails and something has changed.
1s in the 7 data bits
Even parity bit
Odd parity bit
an odd number (1, 3, 5, 7)
1
0
an even number (0, 2, 4, 6)
0
1
Worked examples
Parity bit
Data bits
1s in data
Byte sent
1s in byte
1
0110100
3
10110100
4
Even parity. The data bits are 0110100. There are 3 ones, which is odd. To make the total even, the parity bit must be 1. The byte sent is 10110100, which has 4 ones.
Parity bit
Data bits
1s in data
Byte sent
1s in byte
0
0110100
3
00110100
3
Odd parity. The same data bits 0110100 already have 3 ones, which is odd. The parity bit must not change this, so it is 0. The byte sent is 00110100, which has 3 ones.
Byte received
1s counted
Even or odd?
Result
11010011
5
odd
fail
01101100
4
even
pass
10001000
2
even
pass
Checking at the receiver. Both devices agreed on even parity. Three bytes arrive. The receiver counts the 1s in each whole byte. An odd count means a fail, and the receiver knows that at least one bit changed on the way.
Class activity
Bit cards (no computer). Make eight cards: write 1 on one side and 0 on the other. Partner A lays out seven data bits in a row and says ‘even’ or ‘odd’. Partner B counts the 1s and puts the eighth card, the parity bit, on the left. Partner A checks the count of the whole byte. Then swap roles. For a challenge, B turns the cards face down, A turns one card over in secret, and B counts the 1s again and says ‘pass’ or ‘fail’.
Practice
1
The sender uses even parity. Work out the parity bit for each row, and write the byte that is sent.
Data bits
Parity bit
Byte sent
1000101
?
?
0011110
?
?
0000111
?
?
1100110
?
?
1000101 has 3 ones, so the parity bit is 1 and the byte is 11000101. 0011110 has 4 ones, so the bit is 0 and the byte is 00011110. 0000111 has 3 ones, so the bit is 1 and the byte is 10000111. 1100110 has 4 ones, so the bit is 0 and the byte is 01100110.
2
The sender uses odd parity. Work out the parity bit for each row.
Data bits
Number of 1s
Parity bit
1010100
?
?
0111111
?
?
0000000
?
?
1111111
?
?
1010100 has 3 ones (odd already), so the parity bit is 0. 0111111 has 6 ones, so the bit is 1. 0000000 has 0 ones, so the bit is 1. 1111111 has 7 ones, so the bit is 0.
3
Both devices use odd parity. Count the 1s in each received byte and say whether it passes or fails.
Byte received
1s counted
Pass or fail?
10110110
?
?
01001100
?
?
11001100
?
?
10110110 has 5 ones (odd), so it passes. 01001100 has 3 ones (odd), so it passes. 11001100 has 4 ones (even), so it fails.
4
A learner says: ‘The data bits 1011000 have three 1s, which is an odd number, so with even parity the parity bit is 0.’ Find the mistake and give the correct byte.
With even parity the whole byte must have an even number of 1s. Three 1s is odd, so the parity bit must be 1 to make four. The correct byte is 11011000.