Parity Bit Calculator
Parity bit
0
How it works
A parity bit is a single bit added to a binary word to make the total number of 1-bits either even (even parity) or odd (odd parity). It provides single-bit error detection — any single bit flip changes the parity, which is detected on receipt.
**Even vs. odd parity** Even parity: parity bit is chosen so total 1-bits is even. If data has 3 ones, parity bit = 1 (making total 4 = even). Odd parity: parity bit ensures total 1-bits is odd. USB uses CRC for error detection; UART serial communication often uses parity bits for simple checking.
**Limitations of parity** Parity detects only odd numbers of bit errors. Two bit errors in the same word leave parity unchanged — undetected. Parity cannot locate or correct errors; it only indicates whether an error occurred. For error correction, Hamming codes add multiple parity bits that together identify the error position.
**Parity in memory** ECC (Error Correcting Code) memory uses Hamming-based parity across multiple bits to detect and correct single-bit errors and detect double-bit errors. Server and workstation RAM typically uses ECC; consumer RAM often doesn't. A single cosmic ray can flip a memory bit — ECC prevents the resulting silent data corruption.
**Vertical and horizontal parity (LRC/VRC)** Longitudinal Redundancy Check (LRC): parity computed across rows of a block. Vertical Redundancy Check (VRC): parity per byte. Together, they form a two-dimensional parity matrix that detects most burst errors. More commonly, CRC-16 or CRC-32 replaces this approach in modern protocols.
Frequently Asked Questions
- UART (Universal Asynchronous Receiver/Transmitter) can optionally append a parity bit to each 7 or 8-bit character frame. Even parity: parity bit set so total 1-bits (including parity bit) is even. Odd parity: total is odd. Both sender and receiver are configured for the same parity type. If a received frame has incorrect parity, a 'parity error' flag is set. UART parity only catches single-bit errors — two bit flips cancel. Most modern systems use no parity (rely on higher-level CRC checking) or 9-bit frames for address detection in multi-drop networks. 8N1 (8 data bits, no parity, 1 stop bit) is the most common UART format.
- Simple parity: one extra bit — detects any odd number of errors, corrects none. Hamming(7,4) code: 4 data bits + 3 parity bits = 7 total bits — detects 2-bit errors, corrects any 1-bit error. Each parity bit covers a specific subset of data bits (positions based on powers of 2). The syndrome (pattern of which parity checks fail) directly points to the error position. Hamming codes are the foundation of ECC memory. Extended Hamming codes add one more parity bit, allowing detection of double errors while correcting single errors (SECDED — Single Error Correct Double Error Detect).
- ECC (Error Correcting Code) memory uses SECDED Hamming code across each 64-bit data word plus 8 check bits (72 bits total per access). The check bits are computed over specific bit positions. On read, check bits are recomputed and compared to stored values — syndrome bits identify any single-bit error and its exact position, which is then flipped (corrected). Double-bit errors are detected (but not corrected) — the server logs the event and can be serviced. Cosmic rays, alpha particles, and electromagnetic interference cause roughly 1 memory error per GB per hour in unprotected DRAM — ECC prevents these from causing silent data corruption.
- Simple parity: XOR of all bits (1-bit result — loses magnitude information). Checksum: arithmetic sum of all bytes modulo 256 (or 2^N) — 8-bit result preserves some magnitude information. Internet checksum (TCP/IP): sum of 16-bit words, carry wrapped around (one's complement sum). Both parity and checksums have weaknesses: two equal and opposite errors cancel. CRC (polynomial division): detects all single and double errors, all odd-error-count patterns, and all burst errors shorter than the CRC length — much more powerful. For data integrity: use CRC-32 (files, Ethernet) or CRC-16 (serial comms). Simple checksums are adequate only for detecting random errors in short data blocks.