## Computer Codes:

The second category of codes are those codes which cannot be represented by any analytical relation, hence these codes are also called as non-analytical code.Non-Analytical code. These are the following codes:

### Non-Weighted Codes:

Excess-3 Codes, Gray Codes, BCD greater than 4-bits

### Self Complementing codes:

2421, 5211, Excess-3 (XS-3)

8421 and XS-3

Gray Code

Gray Code

### Error Detection and Correcting Code:

Parity, Hamming Code

## Gray Code

This code also known as a unit distance code. This code is best suited as a shat position encoder. Going from any one position to next position, there is only one bit change in the code. The pattern formed by the gray code is the mirror image, so the code is also called as reflected code. Figure shows the formation of gray code from 1-bit to 2-bits and from 2-bit to 3-bit.

### Binary coded decimal(BCD) :

This code is an extension of decimal code. This code make use of 4-bit binary code for decimal digit 0 through 9. As with 4-bit, we can have 16 combinations, but the valid decimal digit symbols are from 0 to 9, code 1010 to 1111 are invalid code in BCD.

To encode in BCD, 4-bit code of each decimal digit is written to form a valid binary equivalent

Examples

 Decimal —–> 9 10 128 458 89 BCD   —–> 1001 0001 0000 0001 0010  1000 0100 0101 1000 1000 1001

## Self Complementing Codes

### Excess-3 (XS-3) code:

An XS-3 code is obtained by adding 3 with the equivalent decimal of a binary number and again converting it into binary number.

Procedure:

• Convert a binary to its decimal equivalent: e.g. 1001 = 910
• Add 3 to the decimal digit: in XS-3, add 3, so 9+3=12.
• Convert the decimal back to binary : write the binary Code of 12, which is code of 9 in XS-3

 Binary Decimal +3 XS-3 0000 0 0+3 =3 0011 0001 1 1+3=4 0100 0010 2 2+3=5 0101 0011 3 3+3=6 0110 0100 4 4+3=7 0111 0101 5 5+3=8 1000 0110 6 6+3=9 1001 0111 7 7+3=10 1010 1000 8 8+3=11 1011 1001 9 9+3=12 1100

#### Conversion from bigger decimal numbers to XS-3 is also simple:

• To each decimal digit, add 3
• Write equivalent binary code for each number so formed.

Example:

 Decimal 4 810 92010 7310 Add 3 to each digit (4+3) (8+3) 7           11 (9+3)  (2+3)  (0+3) 12       5        3 XS-3 Code 0111   1011 1100    0101  0011

The primary advantage of XS-3 coding over non-biased coding is that a decimal number can be nines’ complemented (for subtraction) as easily as a binary number can be ones’ complemented; just invert all bits.

## Self Complementing:

### Excess-3(XS-3) code

Just complement the bits to get the 9’s complement

 Decimal 6 9 1 XS-3 Code 1001 1100 0100 Complement Bits 0110 0011 1011 9’s complement “(XS-3) – 3” 3 0 8 Summary -> 9’s complement of 6 is 3 9’s complement of    9 is 0 9’s complement of 1 is 8

### 2421BCD:

The weight of the bits is 2, 4, 2, 1 and the numbers formed are:

 2 4 2 1 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 1 1 0 9 1 1 1 1

### 5421 Binary Coded Decimal Code

 5 4 2 1 0 0 0 0 0 1 0 0 0 1 2 0 0 1 0 3 0 0 1 1 4 0 1 0 0 5 0 1 0 1 6 0 1 1 0 7 0 1 1 1 8 1 0 1 1 9 1 1 0 0 10 1 1 0 1 11 1 1 1 0 12 1 1 1 1

### Quiz

1. The BCD equivalent of decimal 64810 =
2. XS-3 equivalent of BCD 8910   =
3. What is 2421 equivalent of 8 =
4. What is the gray code equivalent of decimal 3………..
5. Convert 1010 into gray code =………..

error: Content is protected !!