# Error detection and correction

## Gray Code

Binary Reflected Gray Code (BRGC) was invented by Frank Gray.

Gray Code is popular because it prevents data errors that can occur with pure binary during state changes.

How to covert to Gray code:

1. Find the most significant bit

2. Use XOR on each pair

3. Add the most significant bit to the front

For example:

1011 =

1011 (1 XOR 0 = 1)

1011 (0 XOR 1 = 1)

1011 (1 XOR 1 = 0)

= 1110

## Parity

If its an even number it needs an even number of 1′s and if it is an odd number it needs an odd number of 1′s. We change this by adding 1 or 0.

(A) 0100001 = 0

(B) 1010011 = 0

(C) 100001 = 1

(D) 1001001 = 1

## Majority vite

Majority Vote is a form of error correction, which is better than error detection.

Example:

If we wanted to send the bit pattern: 01011101 the following may be transmitted:

000 111 000 111 111 111 000 111

This bit pattern is checked and if the majority of triplets are 1′s, the bit is taken to be a 1. If the majority of triplets are 0′s, the bit is taken to be a 0.