Sub Menu contents

Unit 3

Creating Graphics & Images Bit by Bit

3.1 Unit Overview

3.2 Paint Pot Tutorial

3.3 Representing Images

3.4 Paint Pot Projects

3.5 Paint Pot Refactoring

3.6 Error Detection

3.7 Parity Error Checking

3.8 Magic 8 Ball

3.9 Persisting Photos

3.10 Map Tour

3.11BB Electronic Documents

3.12 Wrap Up

 

Parity Error Checking

As you learned in the previous lesson, the card "trick" is really not a magic trick at all. It is a very precise algorithm of error checking based on the concept of parity.

In mathematics, parity refers to the evenness or oddness of a number. In the card trick, a parity bit was added to each row and column such that the additional bit would make the row or column have an even number of 1 bits. This is known as even parity. The "trick" would also work if the parity bits were set so as to make each row and column have an odd number of 1 bits. That would be known as odd parity.

It's important to realize that the parity bit is not part of the data. It is redundant, an extra bit, added to the data to allow us to detect if one of the data bits has been flipped from its original value.

Unit Objectives



Parity Error Checking

Suppose you are sending a stream of data to a server. By adding a parity bit, you enable the server to detect some basic transmission errors. For example, if the server expects that every byte will contain an even number of 1s and it detects a byte such as 0001 0101 with an odd number of 1s, it can tell that an error occured. Perhaps the user meant to send 0000 0101 but one of the bits was flipped from 0 to 1 during transmission.

A parity bit is a bit that is added as the first or last bit of a bit string to ensure that the number of bits that are 1 in the bit string are even or odd.

To see how this works, suppose our data are stored in strings containing 7 bits. (You might remember that the ASCII scheme, when it was initially introduced, was a 7-bit code. In practice, a parity bit would be added to the ASCII code so that 1-bit errors could be detected in the resulting 8-bit byte.)

In an even parity scheme the eighth bit, the parity bit, is set to 1 if the number of 1s in the 7 data bits is odd, thereby making the number of 1s in the 8-bit byte an even number. It is set to 0 if the number of 1s in the data is even.

In an odd parity scheme the eighth bit, the parity bit, is set to 1 if the number of 1s in the 7 data bits is even, thereby making the number of 1s in the 8-bit byte an odd number. It is set to 0 if the number of 1s in the data is odd.

Make sure that you do the Parity Magic Exercise and the Self-check at this link and that you update your Google Site Portfolio