Omni Calculator logo

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.

Ready?

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 11 turns into a 00; or
  • A 00 turns into a 11.

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 11 at a specified position; otherwise, add a 00.

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

πŸ™‹ 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 11011101: it contains three 1s.

  • If you chose odd parity, you have to add a 00 at the end: 1101011010.
  • If you chose even parity, the added bit is a 11: 1101111011.

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 22 (modulo? Don't worry: the modulo calculator will solve your doubts!).

Calling our message mm, we define the binary addition as:

βˆ‘imi mod 2\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:

(1+1+0+1) mod 2=3 mod 2=1\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:

(1+1+0+1) mod 2=3 mod 2=1β†’0\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 01100110: Alice computes its parity:

(0+1+1+0) mod 2=0β†’1(0+1+1+0)\ \text{mod}\ 2= 0 \rightarrow 1

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

(0+1+1+0+1) mod 2=1(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 0110101101, but Bob receives 0100101\textcolor{red}{0}01. He computes the parity:

(0+1+0+0+1) mod 2=0(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 0110101101, but she was very unlucky this time, and Bob received 1010110101. He computes the parity.

(1+0+1+0+1) mod 2=1(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 22. 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
Check out 32 similar tech and electronics calculators πŸ’»
3D printing costAmdahl's lawBattery capacity… 29 more
People also viewed…

Chord finder

The chord finder will determine what chord you're hearing/playing based on what notes you detect in the chord.

Significant figures

Perform mathematical operations on significant figures with our calculator. Get step-by-step solutions or use the built-in sig fig counter!

Test grade

With this test grade calculator, you'll quickly determine the test percentage score and grade.

Travel cost - job application edition

Copyright by Omni Calculator sp. z o.o.
Privacy, Cookies & Terms of Service