Advertisement

Parity calculator

Parity has two everyday meanings. In mathematics it says whether a whole number is even or odd, and how the parity of two numbers combines under addition and multiplication. In computer science it is an extra bit that makes the count of one bits even or odd. This page handles both, with only the fields for the chosen topic.

Calculator

A whole number, with an optional minus sign.

A whole number, with an optional minus sign.

Parity of the first number
odd
Parity of the second number
even
Parity of the sum
odd
Parity of the product
even
Result
The first number is odd and the second is even. Their sum is odd and their product is even.
How the parities combine
OperationParityRule
SumoddAn even and an odd number add to an odd number.
DifferenceoddSubtracting a number has the same parity as adding it, so the difference follows the sum rule.
ProductevenAny even factor makes the product even.

Advertisement

How this calculator works

In mathematics a whole number is even when it is divisible by two, and odd otherwise. Only the last digit matters: in base 10 a number ending in 0, 2, 4, 6 or 8 is even, and in base 2 a number ending in 0 is even. The parity of a sum is the sum of the parities modulo two, so even plus even and odd plus odd are even, while even plus odd is odd. A product is odd only when both factors are odd; one even factor makes the whole product even. In computing, a parity bit is an extra bit added to a message so that the total count of one bits is even or odd. Even parity makes the count even, odd parity makes it odd. A receiver checks the count and flags a mismatch, which detects any odd number of flipped bits but cannot identify which bit changed.

Formula

parity of a whole number = its last digit modulo 2, where 0 means even and 1 means odd. sum parity = (parity of a + parity of b) modulo 2. product parity = parity of a x parity of b. even parity bit = count of one bits modulo 2. odd parity bit = 1 minus the even parity bit.

Worked example

In base 10, 7 is odd and 4 is even, so their sum 11 is odd and their product 28 is even. In base 2, 1011 is odd because it ends in 1, and 110 is even because it ends in 0; the sum 10001 is odd and the product 1000010 is even. For the binary message 1011 there are three one bits. Three is odd, so an even parity bit of 1 makes the total four, and an odd parity bit of 0 leaves the total at three.

Advertisement

Frequently asked questions

What does parity mean for a negative number?

The sign does not change parity. A negative number is even or odd if its absolute value is even or odd, so -3 is odd and -4 is even. The calculator ignores the minus sign when it reads the last digit.

Can parity detect two flipped bits?

No. A parity bit detects an odd number of changes. Two flips leave the count of one bits with the same parity, so the check passes even though the message is wrong. Stronger codes such as a Hamming code locate and correct single-bit errors.

What is the difference between mathematics parity and a parity bit?

Mathematical parity classifies a number as even or odd. A parity bit is a communication aid: it is a redundant bit added to a message so the receiver can check the count of ones. Both rest on the same even-or-odd idea.

Why does only the last digit decide parity?

Every place value except the units is a multiple of two, so all the higher digits contribute an even amount. Only the units digit can leave an odd remainder. In base 2 the same argument leaves only the final bit.

Sources

Advertisement