Gray Code and BCD Code(Binary Coded Decimal)

Hello friends, today we learn about gray code and bcd code in it, so let's start

Gray Code and BCD Code(Binary Coded Decimal)
Gray Code and BCD Code(Binary Coded Decimal)

Gray code-:

Digital system process data into discrete form. Many system supplies continuous or analog data nut it should be converted before using it in the digital system. Sometimes Gray code is used for digital system. Gray code belong to the categories of minimum changes code, in which only one bit in the code changes when moving from one code to the next. Gray code is non weighted code it means it does not contain any weight according to its position. The gray code is a reflective digital code which has the special property that any two subsequent numbers code differ by only one bit.


Decimal number

Binary number
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
0110
8
1000
1100
9
1001
1101
10
1010
1111
11
1011
1110
12
1100
1010
13
1101
1011
14
1110
1001
15
1111
1000



BCD Code-:

 BCD stand for binary coded decimal. It is a non weighted binary  code. It is a strait assignment of the binary equivalent. It this code we find binary for individual bit.
For Example -: If we want BCD code for 237 then we have to find three digit binary code for individual digit.


2                    010
3                   011
4                   111


How to get the BCD code of every decimal number?

In order to obtain the BCD equivalent of each decimal digit from the previous numbers, a “weight” or “value” is assigned according to the position the digit occupies.

This “weight” or “value” follows the following order: 8 – 4 – 2 – 1. (It is a weighted code). The last example shows that the number 5 is represented as: 0 1 0 1.
  • The first “0” corresponds to 8,
  • the first “1” corresponds to 4,
  • the second “0” corresponds to 2,
  • the second “1” corresponds to 1.
Decimal BCD
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001

From the chart above: 0x8 + 1×4 + 0x2 + 1×1 = 5

Comments

Popular posts from this blog

First generation of computer | Advantages and Disadvantages of first-generation computers

ASCII CODE AND EBCDIC CODE