Parity is the attribute of a value describing whether it is
even or
odd. For example, one might state that the number 7 has
odd parity while the number 20 has
even parity.
The parity of
permutations (as defined in
abstract algebra) is the
parity of the number of
transpositions into which the permutation can be decomposed. For example (ABC) to (BCA) is even because it can be done by swapping A and B then C and A (two transpositions).
Particles have a
quantum mechanical property of
parity. According to quantum mechanics, the conservation of this parity is equivalent to the laws of physics being
invariant under
mirror reflection. It has been found that parity is not conserved in the
weak force and so the weak force is not invariant under mirror reflection.
In computing and telecommunications, parity is often used for error checking. In this usage, the number of '1' bits are counted in the binary value. There are several types of parity: none, marking, even, and odd. 'None' means there is no parity calculated and a zero-bit is usually inserted (that is, the bit is present but unused or ignored). 'Marking' means that the parity bit is always a '1'. 'Even' and 'odd' parity insert '1' or '0' parity bits so that the total number of '1' is even or odd, including the parity bit. The parity bit is 'stripped off' before the data is used, thus a seven-bit character (or data value) requires eight bits to transmit or store - the seven data bits and the parity bit. Parity is considered a near-trivial error-checking algorithm, the main benefit of which is the ease of calculation. Modern error-checking algorithms use
CRC or
fire codes[?], for example. These codes are more powerful and can often correct errors, while parity can only detect some errors.
An
integer is even
iff it has
2 as a factor; otherwise it is odd. Another way of stating this is that, for any integer N, if N
modulo 2 = 0, then N is even; otherwise, N is odd.
In any integer-base number system, here is how to test for parity:
- If the base is even, the parity of any integer N is the same as the parity of the last digit of N.
- If the base is odd, the parity of any integer N is the same as that of the sum of the digits of N.
See also
All Wikipedia text
is available under the
terms of the GNU Free Documentation License