In mathematics parity can refer to the evenness or oddness of an integer, which, when written in its binary form, can be determined just by examining only its least significant bit.
In information technology parity refers to the evenness or oddness, given any set of binary digits, of the number of those bits with value one. Because parity is determined by the state of every one of the bits, this property of parity—being dependent upon all the bits and changing its value from even to odd parity if any one bit changes—allows for its use in error detection and correction schemes.
In telecommunications the parity referred to by some protocols is for error-detection. The transmission medium is preset, at both end points, to agree on either odd parity or even parity. For each string of bits ready to transmit (data packet) the sender calculates its parity bit, zero or one, to make it conform to the agreed parity, even or odd. The receiver of that packet first checks that the parity of the packet as a whole is in accordance with the preset agreement, then, if there was a parity error in that packet, requests a re-transmission of that packet.
In computer science the parity stripe or parity disk in a RAID provides error-correction. Parity bits are written at the rate of one parity bit per n bits, where n is the number of disks in the array. When a read error occurs, each bit in the error region is recalculated from its set of n bits. In this way, using one parity bit creates “redundancy” for a region from the size of one bit to the size of one disk. See § Redundant Array of Independent Disks below.
In electronics, transcoding data with parity can be very efficient, as XOR gates output what is equivalent to a check bit that creates an even parity, and XOR logic design easily scales to any number of inputs. XOR and AND structures comprise the bulk of most integrated circuitry.
A parity bit, also known as a check bit, is a single bit that can be appended to a binary string. It is set to either 1 or 0 to make the total number of 1-bits either even (“even parity”) or odd (“odd parity”).
The purpose of a parity bit is to provide a simple way to check for errors later. When data is stored or transferred electronically, it’s not uncommon for bits to “flip” — change from a 1 to a 0, or vice versa. Parity checks can detect these errors. For example, to check a binary sequence with even parity, the total number of ones can be counted. If the number of ones is not even, an error is likely to have occurred.
The inherent weakness in this type of error checking is that it can only detect an odd number of errors in the sequence. If an even number of bits are flipped, a parity check will not catch it.
Example parity checking process
The data 10101 is given the even parity bit of 1, resulting in the bit sequence 101011.
This data is transferred to another computer. In transit, the data is corrupted, and the computer receives the incorrect data 100011.
The receiving computer computes the parity: 1+0+0+0+1+1 = 3. It then performs 3 modulo 2 (the remainder of 3 divided by 2), expecting the result 0 which would indicate that the number is even.
Instead, it receives the result 3 modulo 2 = 1, indicating that the number is odd. Because it is looking for numbers with even parity, it asks the original computer to send the data again.
This time, the data comes through with no errors: 101011. The receiving computer calculates 1+0+1+0+1+1 = 4.
4 modulo 2 = 0, indicating even parity. The parity bit is stripped from the end of the sequence, and the data 10101 is accepted.