Whether odd parity is a 1 or a 0 depends on the data being transmitted.
The purpose of the odd parity bit is to ensure that the total number of "1"s in a set of bits, including the parity bit itself, is an odd number. Therefore, the parity bit is calculated based on the data to achieve this specific outcome.
- If the data being sent already contains an odd number of "1"s, the odd parity bit is set to 0. This keeps the total count of "1"s odd.
- If the data contains an even number of "1"s, the odd parity bit is set to 1 to make the total count of "1"s an odd number.
The purpose of parity
Parity checking is a simple, effective method for detecting errors in digital data during transmission or storage. In binary systems, data is sent as a stream of 0s and 1s, but interference, noise, or hardware faults can cause one or more bits to "flip"—for example, a 1 becomes a 0 or vice versa.
To guard against this, an extra bit, the parity bit, is added to each data unit (e.g., a byte). The sender and receiver must agree beforehand on which type of parity they will use, even or odd. The receiver then checks the parity of the incoming data to see if it matches the expected type.
How odd parity works step-by-step
Let's walk through the odd parity calculation with two examples.
Example 1: Data with an even number of "1"s
Suppose you want to send the 8-bit data byte 11010010.
- Count the "1"s: The data byte
11010010contains four "1"s (an even number). - Calculate the parity bit: Because the count of "1"s is even and the system is using odd parity, the parity bit must be a 1 to make the total count odd.
- Append the parity bit: The full codeword sent would be
110100101. - Verification: The total number of "1"s is now five, which is odd.
Example 2: Data with an odd number of "1"s
Now, consider the 8-bit data byte 01100101.
- Count the "1"s: The data byte
01100101contains four "1"s. Whoops, wait. The example used here seems to have an error. Let's find one with an odd number of "1"s. Consider the byte11010100. It contains four 1s. - Count the "1"s: The data byte
11010100has four 1s (an even number). Let's pick a different example. Consider the data byte10110000. This has three 1s. - Count the "1"s: The data byte
10110000contains three "1"s (an odd number). - Calculate the parity bit: Since the count of "1"s is already odd, the odd parity bit is set to 0 to keep the total count odd.
- Append the parity bit: The full codeword sent would be
101100000. - Verification: The total number of "1"s is still three, which is odd.
Odd parity vs. even parity
The logic for odd parity is a reversal of even parity:
- Odd Parity: The goal is to make the total number of "1"s odd.
- Even Parity: The goal is to make the total number of "1"s even.
In even parity, the parity bit is 1 if the data has an odd number of "1"s and 0 if it has an even number. The choice between even or odd parity depends on the system design, and either method is equally effective for basic error detection.
Limitations of parity checking
While parity checking is simple and fast, it has significant limitations:
- Cannot detect multiple errors: If two bits in a data stream are flipped, the parity may still be correct, causing the error to go undetected. For example, in odd parity, if a 0 flips to a 1 and a 1 flips to a 0, the count of 1s will not change, and the error will be missed.
- Cannot correct errors: Parity checking can only signal that an error has occurred; it cannot identify which specific bit is incorrect. To fix the error, the receiver must request a retransmission of the data.
- Limited reliability: In noisy channels, where multiple bit errors are more common, basic parity checking is not as effective.
Modern alternatives
Because of these limitations, modern systems often use more robust error-detection and error-correction methods.
- Cyclic Redundancy Checks (CRC): These are widely used in networking and storage for more reliable error detection.
- Forward Error Correction (FEC): Techniques like Hamming codes introduce more redundant data, allowing the receiver to not only detect errors but also correct them without retransmission.
- RAID: This technology uses parity information across multiple drives to reconstruct lost data if a drive fails.
Despite the existence of more advanced methods, parity checking remains a useful and simple tool for basic error detection in low-resource environments and legacy systems.