# Parity Bit Calculator

Created by Davide Borchia
Reviewed by Anna Szczepanek, PhD and Adena Benn
Last updated: Feb 02, 2023

Even if it sounds odd, our parity bit calculator will introduce you to the field of error detection.

Errors happen all the time when transmissions are involved. Here you will learn how to quickly understand if corruption of a message occurred — at least when it's possible to do so!
We will discover:

• What is an error, and why do we need to look for them;
• What are parity bits and the types of parity bits;
• How to use parity bits in error detection;
• The limitations of parity bits; and
• Some examples and instructions for our parity bit calculator.

## What is an error?

In computer science and information theory, errors are corruptions of a message. Usually, messages are binary strings, which means sequences of 0s and 1s (visit our binary converter for a refresh on the matter).

We can call the messages "words". This allows us to say that the alphabet, in our case, is made of binary digits.

If your alphabet is binary, your errors are bit flips, instances where:

• A $1$ turns into a $0$; or
• A $0$ turns into a $1$.

Errors are dangerous: they can cause computers to crash or send the wrong message, and we don't want that! What to do, then?

## Error detection and correction

With the coming of the Computer Age and the proliferation of transmissions (particularly digital transmission) came the need for protocols to identify errors. Richard Hamming was a pioneer in error detection and correction.

Here, at Omni Calculator, we have already covered many of his works: check out our Hamming codes calculator and the Hamming distance calculator!

The general idea behind searching — and correcting — errors is to count bits. The technique used may be relatively complex (but efficient) like in Hamming codes or simple like the parity check.

## What is a parity bit?

The laws of Nature tell you that if you want to inform the receiver of your message about the presence — or lack thereof — of errors in your transmission, you have to add bits to your message, bits that will contain that information.

The simplest example of this addition is the parity bit.

There are two types of parity bits:

• Odd parity bits; and
• Even parity bits.

## How to calculate an odd or even parity bit

Calculating a parity bit, even or odd, is a straightforward thing to do.

For odd parity, count the 1s in the message, and if their number is even, add a $1$ at a specified position; otherwise, add a $0$.

For even parity, do the opposite: if the number of 1s is even, add a $0$; otherwise, add a $1$.

🙋 There is no rule that fixes the position of the parity bit; however, it is added conventionally at the end of the message.

Ok, it may not sound that easy: look at these examples.

Take the message $1101$: it contains three 1s.

• If you chose odd parity, you have to add a $0$ at the end: $11010$.
• If you chose even parity, the added bit is a $1$: $11011$.

There is a helpful mathematical operation to write this process in rigorous terms: binary addition. This binary operation is nothing but the sum of the values of the bit in a binary message, modulo $2$ (modulo? Don't worry: the modulo calculator will solve your doubts!).

Calling our message $m$, we define the binary addition as:

$\sum_i m_i\ \text{mod}\ 2$

If we calculate an even parity bit, we take the result as is. If we are using an odd parity bit, we take the one's complement of the result.

Let's take a look at the example!

🙋 For a refresh on the binary operations we use while calculating the parity bit, visit our binary addition calculator and our binary calculator! 01001001...

For the even parity, the value of the parity bit is:

\begin{align*} & (1+1+0+1)\ \text{mod}\ 2 = \\ & 3\ \text{mod}\ 2= 1 \end{align*}

When we are considering an odd parity bit, instead, the result must be "reversed" before use:

\begin{align*} & (1+1+0+1)\ \text{mod}\ 2 = \\ & 3\ \text{mod}\ 2= 1 \rightarrow 0 \end{align*}

## Parity bits for the detection of errors

Now you know how to add a parity bit to your message. But what's their purpose?

Imagine that Alice sends Bob a binary message. They agreed beforehand to use a specific type of parity, let's say, odd parity.

💡 Alice and Bob are the two people traditionally used in information theory when making examples. The names were chosen randomly to follow the alphabetic order; Charlie comes next. If someone is listening to the message, it's usually a bad guy (or girl, in fact), and we call her Eve, from eavesdropper.

The message is $0110$: Alice computes its parity:

$(0+1+1+0)\ \text{mod}\ 2= 0 \rightarrow 1$

And adds the parity bit at the end: $01101$. Bob receives the message and computes the overall parity:

$(0+1+1+0+1 )\ \text{mod}\ 2= 1$

🙋 Notice how the addition of an even (odd) parity bit makes the overall number of 1s in a message even (odd)!

He finds an odd result: the parity of the message and the parity bit agree. Bob knows that there are no single-bit errors in the message.

Let's flip a bit and see what happens. Alice transmits $01101$, but Bob receives $01\textcolor{red}{0}01$. He computes the parity:

$(0+1+0+0+1 )\ \text{mod}\ 2= 0$

Bob knows that the number of 1s in the message should be odd, and he understands that something went wrong. Alice has to send the message again.

🔎 The same reasoning applies if the parity bit is the one flipping: check it!

The position of the parity bit doesn't really matter, since it changes the overall parity of the message. However, the convention is to add it to the end of the message. Try it without the calculator!

What if two bits flipped during the transmission?

We will now see the limitations of parity bits in error detection. Alice transmitted the usual message $01101$, but she was very unlucky this time, and Bob received $10101$. He computes the parity.

$(1+0+1+0+1 )\ \text{mod}\ 2= 1$

It checks out! The number of 1s is odd, so everything should be fine, right?

No. A single parity bit can't give information on an error involving two bits. It can inform of a mistake happening on three bits, but we would not be able to discriminate it from single-bit errors.

🙋 We say that parity bit error detection has Hamming distance equal to $2$. This means that it is enough to flip two bits to obtain a new "uncorrupted" message from another.

## How to use our parity bit calculator

It doesn't matter if you want to calculate even parity bit or odd parity bit or if you want to encode or analyze a message. Our parity bit calculator can help you!

If you want to generate a parity bit, select generate in the first menu. It is the default choice. Then choose the type of parity, even or odd, and finally insert both the message and the position where you want the parity bit to be (the default is at the end of the message). We will generate the parity bit and print the message, ready for your transmissions!

If you want to check if a message was corrupted or not, select check, choose the parity, and insert the message: we will tell you as much as we can, but remember: only single-bit errors can be detected!

## A final bit on parity bits

Hamming codes, parity bits, and Hamming distance are only some of the inhabitants of the complex and interconnected world of information theory. Our dedicated calculators can help you understand it. We hope our message reached you without errors! 😉

## FAQ

### What are parity bits used for?

We use parity bits to detect errors during the communication of information. A message can suffer from interference, and the addition of a bit that gives information on the number of ones or zeroes in a string can tell us if corruption happened. Parity bits are limited because they can't help locate the error.

### What is a parity bit?

A parity bit is a bit added to a binary message that carries information about the number of 1s in the string itself. There are two types of parity, even and odd. Even parity bits ensure that the number of ones in the message is even, and vice-versa for odd parity bits.

### How to calculate the parity bit of the message 011101?

To calculate the parity of 011101 take the sum of the ones in the message and compute its modulo 2:
(1 + 1 + 1 + 1) mod 2 = 4 mod 2 = 0
The even parity bit is 0, and we transmit the message 0111010.

### How to calculate the parity bit?

To calculate an even parity bit, follow these instructions:

1. Calculate the sum of the ones in the message,
2. Take the modulo 2 of this result; and
3. Attach the result to your message.

The number of ones in the message is now even. To calculate an odd parity bit:

1. Count the ones in your message;
2. Take the modulo 2 of the sum;
3. Take the complement; and
4. Attach it to the message.

The number of ones is now odd.

Davide Borchia
What to do?
Generate
Type of parity
Odd
Message
Parity bit position
People also viewed…

### BMR - Harris-Benedict equation

Harris-Benedict calculator uses one of the three most popular BMR formulas. Knowing your BMR (basal metabolic weight) may help you make important decisions about your diet and lifestyle.

### Coffee kick

A long night of studying? Or maybe you're on a deadline? The coffee kick calculator will tell you when and how much caffeine you need to stay alert after not sleeping enough 😀☕ Check out the graph below!

### Harmonic series

Discover the fundamentals of music with our harmonic series calculator.

### Video file size (by format)

The video file size calculator determines how much space a video takes up on your disk, depending on the video format and compression. 