0000000  0  00000000  10000000 
1010001  3  10100011  01010001 
1101001  4  01101001  11010011 
1111111  7  11111111  01111111 
A parity bit, or check bit, is a bit added to a string of binary code to ensure that the total number of 1bits in the string is even number or odd number. Parity bits are used as the simplest form of error detecting code.
There are two variants of parity bits: even parity bit and odd parity bit.
In the case of even parity, for a given set of bits, the occurrences of bits whose value is 1 is counted. If that count is odd, the parity bit value is set to 1, making the total count of occurrences of 1s in the whole set (including the parity bit) an even number. If the count of 1s in a given set of bits is already even, the parity bit's value is 0.
In the case of odd parity, the coding is reversed. For a given set of bits, if the count of bits with a value of 1 is even, the parity bit value is set to 1 making the total count of 1s in the whole set (including the parity bit) an odd number. If the count of bits with a value of 1 is odd, the count is already odd so the parity bit's value is 0.
Even parity is a special case of a cyclic redundancy check (CRC), where the 1bit CRC is generated by the polynomial x+1.
If a bit is present at a point otherwise dedicated to a parity bit, but is not used for parity, it may be referred to as a mark parity bit if the parity bit is always 1, or a space parity bit if the bit is always 0. In such cases where the value of the bit is constant, it may be called a stick parity bit even though its function has nothing to do with parity.What is the difference between using mark or space parity and paritynone [1] The function of such bits varies with the system design, but examples of functions for such bits include timing management, or identification of a packet as being of data or address significance.What is the purpose of the Stick Parity? [2] If its actual bit value is irrelevant to its function, the bit amounts to a Don'tcare term.Serial Communications  SatDigest[3]
Parity bits are generally applied to the smallest units of a communication protocol, typically 8bit octets (bytes), although they can also be applied separately to an entire message string of bits.
Parity bit checking is used occasionally for transmitting ASCII characters, which have 7 bits, leaving the 8th bit as a parity bit.
For example, the parity bit can be computed as follows, assuming we are sending simple 4bit values 1001.
A wants to transmit: 1001
A computes parity bit value: 1+0+0+1 (mod 2) = 0 A adds parity bit and sends: 10010 B receives: 10010 B computes parity: 1+0+0+1+0 (mod 2) = 0 B reports correct transmission after observing expected even result. 
A wants to transmit: 1001
A computes parity bit value: 1+0+0+1 + 1 (mod 2) = 1 A adds parity bit and sends: 10011 B receives: 10011 B computes overall parity: 1+0+0+1+1 (mod 2) = 1 B reports correct transmission after observing expected odd result. 
This mechanism enables the detection of single bit errors, because if one bit gets flipped due to line noise, there will be an incorrect number of ones in the received data. In the two examples above, B's calculated parity value matches the parity bit in its received value, indicating there are no single bit errors. Consider the following example with a transmission error in the second bit using XOR:
Even parity Error in the second bit  A wants to transmit: 1001
A computes parity bit value: 1^0^0^1 = 0 A adds parity bit and sends: 10010 ...TRANSMISSION ERROR... B receives: 1 1010 B computes overall parity: 1^1^0^1^0 = 1 B reports incorrect transmission after observing unexpected odd result. 
Even parity Error in the parity bit  A wants to transmit: 1001
A computes even parity value: 1^0^0^1 = 0 A sends: 10010 ...TRANSMISSION ERROR... B receives: 1001 1 B computes overall parity: 1^0^0^1^1 = 1 B reports incorrect transmission after observing unexpected odd result. 
There is a limitation to parity schemes. A parity bit is only guaranteed to detect an odd number of bit errors. If an even number of bits have errors, the parity bit records the correct number of ones, even though the data is corrupt. (See also error detection and correction.) Consider the same example as before with an even number of corrupted bits:
Even parity Two corrupted bits  A wants to transmit: 1001
A computes even parity value: 1^0^0^1 = 0 A sends: 10010 ...TRANSMISSION ERROR... B receives: 1 101 1 B computes overall parity: 1^1^0^1^1 = 0 B reports correct transmission though actually incorrect. 
In serial data transmission, a common format is 7 data bits, an even parity bit, and one or two . This format neatly accommodates all the 7bit ASCII characters in a convenient 8bit byte. Other formats are possible; 8 bits of data plus a parity bit can convey all 8bit byte values.
In serial communication contexts, parity is usually generated and checked by interface hardware (e.g., a UART) and, on reception, the result made available to the CPU (and so to, for instance, the operating system) via a status bit in a hardware register in the interface hardware. Recovery from the error is usually done by retransmitting the data, the details of which are usually handled by software (e.g., the operating system I/O routines).
When the total number of transmitted bits, including the parity bit, is even, odd parity has the advantage that the allzeros and allones patterns are both detected as errors. If the total number of bits is odd, only one of the patterns is detected as an error, and the choice can be made based on which is expected to be the more common error.
For example, suppose two drives in a threedrive RAID 5 array contained the following data:
Drive 1: 01101101
Drive 2: 11010100
To calculate parity data for the two drives, an XOR is performed on their data:
01101101
XOR 11010100
_____________
10111001
The resulting parity data, 10111001, is then stored on Drive 3.
Should any of the three drives fail, the contents of the failed drive can be reconstructed on a replacement drive by subjecting the data from the remaining drives to the same XOR operation. If Drive 2 were to fail, its data could be rebuilt using the XOR results of the contents of the two remaining drives, Drive 1 and Drive 3:
Drive 1: 01101101
Drive 3: 10111001
as follows:
10111001
XOR 01101101
_____________
11010100
The result of that XOR calculation yields Drive 2's contents. 11010100 is then stored on Drive 2, fully repairing the array. This same XOR concept applies similarly to larger arrays, using any number of disks. In the case of a RAID 3 array of 12 drives, 11 drives participate in the XOR calculation shown above and yield a value that is then stored on the dedicated parity drive.
Parity was also used on at least some papertape (punched tape) data entry systems (which preceded magnetic tape systems). On the systems sold by British company ICL (formerly ICT) the paper tape had 8 hole positions running across it, with the 8th being for parity. 7 positions were used for the data, e.g., 7bit ASCII. The 8th position had a hole punched in it depending on the number of data holes punched.

