### Digital Codes

DIGITAL CODES:

When any number, letters, or word are represented by a special group of symbol or character we can say that they are being encoded and the group of symbol is called “CODE”

Various type of code are given

Non-Binary code: In non binary code system series of dots and dashes represents the letters of alphabet morse code is an example of non binary code

Binary code: In binary code system information is coded in group of binary digits examples are 8-4-2-1 code, BCD code , Excess-3 code , Gray code Error detecting and error correcting code

Alphanumeric code: In this code system information is coded in a set of elements that include the 10 decimal digits,the 26 letters of alphabet , and a number of special character

examples are ASCII code, EBCDIC code, Baudot code , Hollerith Code

(1)ASCII code:

It is called American standard Code for Information Interchange

It is a 7bit+1bit parity code system

It uses  7bit  to code 128 characters and 1bit may be employed to indicate the parity of character

= total 128 character

For example letter A is represented in ASCII code as 1000001 + 1bit parity

(2) EBCDIC code:

It is called Extended Binary Coded Decimal Interchange Code

It uses 8bit for each character

= total 256 character

EBCDIC has same character symbol as ASCII code but bit assignment for character is different

(3) Baudot code:

It is a 5bit code

Baudot code represent 58 character with 5bit

(4) Hollerith Code:

In this code system information is coded with 12 bit

(5) Straight Binary code:

Only 2 symbols 1 and 0 are use to represent any digital information

(6) BCD code:

Full form of BCD is Binary Coded Decimal

In this code system each digit of a decimal number is represented by 4 bit binary equivalents

It is also called 8-4-2-1 code system

This is a weight code and arithmetic operation can be performed using this code

BCD code and Binary code for Decimal number 0 to 9 are exactly same

A disadvantage of BCD code system is , its required more number of bits to code a decimal number

An advantage of BCD code system is, it is very convenient and useful code for input and output operation in digital system

In table below Decimal and its Binary and BCD code is given

Decimal      Binary             BCD

0                  0000                  0000

1                   0001                  0001

2                   0010                 0010

3                   0011                  0011

4                   0100                 0100

5                    0101                  0101

6                    0110                 0110

7                     0111                 0111

8                    1000                1000

9                     1001               1001

Example: Convert Decimal number 150 to its BCD code

Solution: For converting Decimal number 150 to BCD code ,we have to write 4bit binary equivalent of each digit in given Decimal number

150  =        1         5         0

(0001)(0101)(0000) =000101010000 – BCD code of 150

Example: Convert Decimal number 8.1 to its BCD code

Solution:

8.1 =         8    .    1

(1000).(0001) = 1000.0001 –BCD code of 8.1

Example:Find the Deimal number represented by the following BCD code

(a) 10000100  (b) 00110011  (c) 10100  (d) 1000.0010

Solution: To convert a BCD code into Decimal code , Start at the decimal point(from most right hand side) and break the code into group of 4 bits binary. Then write the decimal digit represented by each 4 bit group of binary

BCD  code     4bit grouping     Decimal code

(a) 10000100 = (1000)(0100) =  (8)(6)=86

(b) 00110011 = (0011)(0011) =  (3)(3)=33

(c) 10100 =  (1)(0100)  =(0001)(0100) =(1)(4)=14

(d)1000.0010 =  (1000).(0010) = (8).(2) = 8.2

(7) Excess-3 code:

It is an another form of BCD code system , in which each digit of decimal number is coded into 4bit binary number and to obtained Excess-3 code add 4bit binary code of decimal number 3 to each 4bit group BCD code

Example : Convert Decimal number 5 to Excess-3 code

Decimal number                  5

BCD code                             0101

Add 4bit binary of 3          0101

in above BCD code         + 0011

Excess-3 code                     1000

Another way to obtain Excess-3 code from a decimal code by adding 3 to each decimal digit and then convert the each digit of result in the group of 4 bit binary

Example: Convert each of the following decimal number to Exess-3 code

(a) 31 (b) 5112

Solution: (a) 31

Decimal number         3    1

Add 3 to each           +3  +3

Digit

Result                         6    4

4bit binary

Code of each        (0110) (0100)

Digit

Excess-3 code       01100100

(b) 5112

Decimal number        5        1        1         2

Add 3 to each          +3     +3     +3     +3

Digit

Result                        8        4       4         5

4bit binary code   (1000)(0100)(0100)(0101)

Of each digit

Excess-3 code         1000010001000101

Excess-3 code is self-complementing that means 1s complement of an Excess-3 number is the Excess-3 code for the 9s complement of corresponding decimal number

Example:

Excess -3 code for Decimal 3 is 0110

1s complement of 0110 is 1001 which is Excess-3 code of Decimal 6

Decimal 6 is the 9s complement of Decimal 3

Excess-3 code is an unweighted code which means that there is no specific weight assigned to the bit position

Excess-3 code is useful in some arithmetic operation because 9s complement is used for subtraction

(8) Gray Code:

Gray code is unweighted code which means that there is no specific weight assigned to the bit position

Gray Code is called “ Minimum change code” which means that this code Exhibits only a single bit change from one code number to next code and this is the advantage of Gray code over Binary code system

Gray code is not an Arithmetic code

Gray code can have any number of bits

Gray code is also known as Reflected code

MSB (most significant bit ) of gray code and Binary Code is always same

Decimal Number  Binary code   Gray Code

0                                  0000                   0000

1                                  0001                     0001

2                                  0010                     0011

3                                  0011                      0010

4                                   0100                     0110

5                                    0101                      0111

6                                    0110                      0101

7                                    0111                        0100

8                                    1000                      1100

From above gray code numbers it is clear that any number code is differ by one bit

Binary code to Gray code Conversion:

Example : Convert Binary code 10100 to Gray Code

Solution:

Step(1):   1  0  1  0  0       given Binary  Code

1                       Gray code

Step(2):   1 + 0  1  0  0     given Binary Code

1    1                 Gray Code

Step(3):   1   0 + 1 0  0    given Binary Code

1   1   1            Gray Code

Step(4):    1  0  1 +0  0    given Binary Code

1  1   1   1         Gray Code

Step(5):   1  0  1  0 + 0     given Binary Code

1   1  1  1   0       Gray Code

Therefore Gray code for given binary code 10100 will be 11110

(9) Octal code:

It is 3-bit binary code

In octal code all octal decimal digit from 0 to 7 is coded into 3-bit straight binary number

Code for octal digit 5 will be 101