**a) Gray Code:-**

- Gray Code is non- weighted code and is a special case of unit-distance code.
In unit-distance code, bit pattern for two consecutive number differ in only one bit position.

These codes are also called as cyclic code for Example;

Gray cod for decimal number 5 is 0 1 1 1 and

Gray cod for decimal number 6 is 0 1 0 1 .

These two codes only differs by one bit position.

This code is extensively used in shaft encoder because of this property.

- Gray Code is reflected code.
Gray code can be constructed using following property.

i) A 1 Bit Gray Code has two code words 0 and 1 representing Decimal No. 0 and 1 respectively.

ii) An (n-bit) n>2 Gary Code will have first 2n-1 Gray Codes of (n-1) bit written in order write leading 0 appended.

iii) The last 2n-1 Gray Code will be equal to Gray Code words of an (n-1) bit Gray Code, written in reverse order.

**b) Excess-3 Code**

- This is another form BCD Code, on which each Decimal Digit is coded into 4-bit Binary code.
The code for each Decimal Digit obtained by adding 3 to natural BCD code of the digit.

For Example,2 is loaded as

- It is not-weighted code
This code is self – complementing code, which means 1’s complement of the coded number yields 9’s complement of number itself

For Example,

Excess-3 Code for 2 is 0 1 0 1 and it’s 1’s complement is 1 0 1 0 which is Excess-3 code for decimal 7, which is 9’s complement of 2

- The self – complementing property of this code used in performing subtracting operation in digital system.
- Excess-3 code for decimal 0 through 9 given below :

Decimal Digit | Excess-3 Code |
---|---|

0 | 0 0 1 1 |

1 | 0 1 0 0 |

2 | 0 1 0 1 |

3 | 0 1 1 0 |

4 | 0 1 1 1 |

5 | 1 0 0 0 |

6 | 1 0 0 1 |

7 | 1 0 1 0 |

8 | 1 0 1 1 |

9 | 1 1 0 0 |