Sie sind auf Seite 1von 12

CODING

Binary code
Digital data is represented, stored and transmitted as group of binary bits. This group is called binary code. The binary code can be used for represent the number as well as alpha numeric letters.

Classification of binary code


Binary code

Non weighted code Example: Gray Excess-3 Five bit BCD

Reflective code

Sequential code

Error detecting and correcting code

Weighted code

Example: 5211 2421 Excess-3

Example: 8421 Excess-3

Example: Hamming Parity

Binary Ex: 0s1

BCD Ex: 8421 2421 5211 4221

Binary code decimal (BCD)


We know that decimal, octal, hexadecimal can be represented by binary digit.
Not only numbers but letters and other symbols can be represented by 1s 0s. Combination of binary digits that represent all these things are called digital codes.

Binary code decimal (BCD)


8421 (BCD) 0000 0001 Decimal 0 1

0010
0011 0100 0101 0110

2
3 4 5 6

0111
1000 1001

7
8 9

Gray code
It is called cyclic or reflected code. In this code each code group does not differ from its neighbour in more than one bit. This code is used for input and output devices in digital system.

Table of gray code


Decimal number 0 1 2 3 4 5 6 7 8 9 10 11 12 Gray code 0 0 0 0 0 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 0 1 0 1 0

Conversion from binary to gray code


Method: Write down binary form of the given decimal number. Write MSB as such. Then add the binary digit from left to right at the adjacent position. Discard carry if any. Write the digit which comes after addition.

Conversion from binary to gray code


Example: Convert 15 into gray code.

Solution: (15)10 = (1111)2 We have to convert (1111)2 into gray code


Left most bit

1 1

1 0

1 0

1 0

Hence the resultant gray code is 1000 for 15.

Example
Convert (111011)2 into gray code. Solution:

Left most bit

1 1

1 0

1 0

0 1

1 1

1 0

1. 2. 3.

Write the left most bit as such. Then add the binary digit from left to right at the adjacent position. Write the digit which comes after addition.

Hence the grey code of (111011)2 is 100110.

Conversion from grey code to binary code


1. Method: Write the given grey code.

2.
3.

Write the left most bit as such.


Add this bit to the second left most bit, write the result, discard carry. Add this result to the next left most bit diagonally.

4.

Conversion from grey code to binary code


Example: Convert the following grey code into binary code from (1 0 0 0). Solution:

We have Left most bit

1
+

0 1

0 1

0 1

Hence the corresponding binary number us (1111)2.

Das könnte Ihnen auch gefallen