Skip to main content

🔄 Parity Checking

🔄 Error Detection with Parity Bits

Parity checking is a simple but effective method for detecting errors in data transmission and storage. It adds an extra bit (the parity bit) to detect whether an odd number of bits have been changed during transmission.

🧮 What is Parity?

Parity refers to whether the number of 1s in a binary data item is even or odd:

  • 🔢 Even parity: The total number of 1s is even
  • 🔢 Odd parity: The total number of 1s is odd

A parity bit is an extra bit added to make the total number of 1s either even or odd, depending on the parity scheme being used.

⚙️ How Parity Checking Works

🔄 Even Parity

In even parity, the parity bit is set so that the total number of 1s (including the parity bit) is even:

  • 0️⃣ If the data already has an even number of 1s, the parity bit is set to 0
  • 1️⃣ If the data has an odd number of 1s, the parity bit is set to 1

🔄 Odd Parity

In odd parity, the parity bit is set so that the total number of 1s (including the parity bit) is odd:

  • 0️⃣ If the data already has an odd number of 1s, the parity bit is set to 0
  • 1️⃣ If the data has an even number of 1s, the parity bit is set to 1

📝 Example of Parity Checking

Let's consider the ASCII character 'A' which is represented as 100 0001 in 7-bit binary:

🔢 Even Parity Example

  1. Original data: 100 0001
  2. Count 1s: There are two 1s (odd number)
  3. For even parity, add a 1 as the parity bit: 1100 0001
  4. Now the total number of 1s is three (even)

🔢 Odd Parity Example

  1. Original data: 100 0001
  2. Count 1s: There are two 1s (odd number)
  3. For odd parity, add a 0 as the parity bit: 0100 0001
  4. The total number of 1s remains two (odd)

📝 Simplified Table

Data 1s CountParity TypeDo They Match?Parity Bit
EvenEven✅ Yes0
OddOdd✅ Yes0
EvenOdd❌ No1
OddEven❌ No1

🔍 Error Detection Process

When data is received:

  1. 🔢 Count the number of 1s in the received data (including parity bit)
  2. ✅ Check if the count matches the expected parity (even or odd)
  3. ✓ If it matches, the data is likely correct
  4. ❌ If it doesn't match, an error has been detected

⚠️ Limitations of Parity Checking

Parity checking can only detect an odd number of bit errors:

  • ✅ It will detect 1, 3, 5, etc. bit errors
  • ❌ It will not detect 2, 4, 6, etc. bit errors (as they don't change the parity)

For example, if two bits are flipped (e.g., 0 becomes 1 and 1 becomes 0), the parity remains the same, and the error goes undetected.

🔄 Types of Parity Checking

🔢 Simple Parity Check

  • 1️⃣ One parity bit per data unit (byte or word)
  • 🔍 Can detect single-bit errors within that unit
  • 📡 Most common in simple serial communications

🧩 Block Parity Check

  • 📊 Organizes data into a block (matrix) of rows and columns
  • ➕ Adds parity bits for each row and column
  • 🔍 Can detect and sometimes correct errors
  • 🧮 Example: A 4×4 block would have 4 row parity bits and 4 column parity bits

💻 Applications of Parity Checking

Parity checking is used in various computing contexts:

  • 📡 Serial communications (RS-232, older modems)
  • 🧠 Memory systems (older RAM had parity bits)
  • 💾 Storage systems (some early disk systems)
  • 🌐 Simple network protocols

📈 Beyond Parity: Advanced Error Detection

While parity checking is simple, more sophisticated methods provide better error detection and correction:

  • 🔄 Cyclic Redundancy Check (CRC)
  • 🧮 Checksum methods
  • 🛠️ Hamming codes (can correct single-bit errors)
  • 💿 Reed-Solomon codes (used in CDs, DVDs)

Parity checking remains important as a fundamental concept in error detection and as a building block for more advanced techniques.