Common digital coding

xiaoxiao2021-03-06  55

Common digital coding

1.BCD encoding

In the digital system, various data can be converted to binary code to process, and people are accustomed to using decimal numbers, so the decimal number is still adopted in the input and output of the digital system, so that one of the four binary numbers represent one Decimal number of methods, this binary code for indicating a decimal number is called a binary code code (Binary Coded Decimal), is referred to as the BCD code. It has the form of binary count to meet the requirements of the digital system, and has a characteristic of decimal (only ten active states). In some cases, the computer can also operate directly in this form. Common BCD code indicates a few of them.

(1) 8421 code

This is a wide range of BCD code, is a power code, the rights of its bits are (from the most effective high start to the lowest significant bit) 8, 4, 2, 1.

Example Write the 8421BCD code corresponding to the decimal 563.97D.

563.97D = 0101 0110 0011. 1001 01118421BCD

Example Write 8421BCD code 1101001.010118421BCD corresponding to the decimal number.

1101001.010118421BCD = 0110 1001. 0101 10008421BCD = 69.58D

Be careful when using the 8421BCD code, pay attention to only ten, namely: 0000 ~ 1001. The remaining six encodings 1010, 1011, 1100, 1101, 1110, 1111 are not effective coding.

(2) 2421 yards

The 2421bcd code is also a power code, which is 2, 4, 2, 1 from a high to low, and can also be used to represent a decimal number of decimal numbers.

(3) Yu 3 yards

Yu 3 yards are also a BCD code, but it is no power, but since each code corresponds to the 8421bcd code difference 3, it is called Yu 3 yards, which is generally used, so it is necessary to understand The specific encoding is as follows.

Common BCD coding table

Decimal number 8421BCD code 2421BCD code over 3 yards

0 0000 0000 0011

1 0001 0001 0100

2 0010 0010 0101

3 0011 0011 0110

4 0100 0100 0111

5 0101 1011 1000

6 0110 1100 1001

7 0111 1101 1010

8 1000 1110 1011

9 1001 1111 1100

10 0001,00 0001,0000 0100, 0011

2. Gray reflection code (cyclic code)

The Gray code is an unlimited code. It is characterized by only one number between any two adjacent codes. In addition, only one number is different between the maximum number and the minimum, and it is usually called a Gray reflection or cycle code.

Decimal number of binary number Gray code decimal number of binary numbers

0 0000 0000 8 1000 1100

1 0001 0001 9 1001 1101

2 0010 0011 10 1010 1111

3 0011 0010 11 1011 1110

4 0100 0110 12 1100 1010

5 0101 0111 13 1101 1011

6 0110 0101 14 1110 1001

转载请注明原文地址:https://www.9cbs.com/read-118160.html

New Post(0)