(b) Coding

Source: Internet
Author: User

The second piece records the code.

Encoding: A set of n-bit binary codes used to represent different numbers or other events, called an encoding.

Code word: A specific n-bit combination of the exact meaning, called the code word.

In short, it is understood that coding is a way of expressing binary number sets.

1, decimal number of binary code

the binary encoding of the ① decimal number is a binary representation of 10 decimal digits 0~9.

② decimal number of binary encoding methods are: BCD code, also called 8421 yards; 5421 yards; 2421 yards; 3 yards. Here is the table, but here is the value of 8421 yards; 2421 yards; 3 yards.

③8421 yards : As shown, is the most customary way to represent decimal numbers in binary notation. The highest bit value is 8, the second high is 4, the second low is 2, the lowest bit is 1. So the number represented by a binary number 1001 is 1*8+1*1 = 9. That is, the right to expand is the decimal value.

④2421 yards : The value is less than or equal to 4 o'clock, 2421 yards equals 8421 yards, the value is greater than 4 o'clock equals 8421 yards plus 6.

⑤ remaining 3 yards : 8421 yards plus 0011 for the corresponding value of the remaining 3 yards.

2, gray code

(1) concept : Baidu Encyclopedia is said: In a set of binary number encoding, if any two adjacent binary number only one binary number is different, it is said that this code is gray code.

• Because the maximum number and the minimum number are also only one-digit difference, that is, "end-to-end connection", so also known as cyclic code or reflection code .

(2) binary and gray code conversion : Here the binary is not a BCD code, is the natural binary.

① binary conversion to Gray code :

Conversion method:

The highest bit of the natural binary is the same as the highest bit of the gray code, and then from the lowest side, each one is compared with the left one, the same takes 0, the difference takes 1, (that is, XOR) as the corresponding gray code that bit value.

Examples are more convenient:

110010 Convert to Gray code:

Process diagram:

First the highest level is 1, then the gray code maximum is 1, and then from the lowest position with the left one to compare;

The lowest bit is 0, and its left one is 1, so the lowest bit of gray code is 1;

The second low is 1, its left one is 0, so get the next low gray code is 1;

The next low 0, its left one is 0, so get the next low-level gray code is 0;

...

The second high is 1, and its left one is 1 (that is, the highest bit), so the sub-high of gray code is 0;

This will get Gray code: 101011.

② Gray code to binary code :

Conversion method:

The conversion side is similar, just backwards back; the highest bits of the Gray code are retained as the highest bit of natural binary code, while the secondary high natural binary code is the highest bit natural binary code and the second high gray code is different or (that is, the same fetch 0, the difference takes 1), And the rest of the natural binary code is similar to the second high-level natural binary code.

For example:

Convert Gray code 101101 to binary number:

Process diagram:

The conversion process is no longer detailed.

(3) features of gray code :

Baidu Encyclopedia summarized as follows:

① code is a reliability coding , which is a kind of error minimization coding method.

• Natural binary codes can be converted directly from a D/a converter to analog signals, but in some cases, such as converting from decimal 3 to 4 o'clock, each bit of the binary code changes, enabling the digital circuit to generate a large spike current pulse.

• Gray code does not have this disadvantage, when it is converted between adjacent bits, only one produces a change. It greatly reduces the confusion of logic from one state to the next.

• Due to the fact that there is only one difference between the two code groups adjacent to the gray code, so in the direction of rotation displacement-digital conversion, when the direction of the angular displacement of a small change (and may cause the digital change, gray code only change one bit, so that with other codes change two or more bits of the case compared to more reliable, Can reduce the likelihood of errors.

② Gray Code is an absolute encoding method , the typical gray code is a kind of reflection and cyclic characteristics of the single-step self-complement, its cycle, single-step characteristics to eliminate the random number of significant errors in the possible, its reflection, self-reinforcing properties make it very convenient to reverse.

③ Gray code is a variable weight code, each bit code does not have a fixed size, it is difficult to directly compare the size and arithmetic operations, can not be directly converted to liquid level signal, to pass the code transformation, into a natural binary code, and then read by the host computer.

④ typical gray code is a quasi-code with absolute encoding, the absolute value of which is 2^i-1 (set the lowest bit i=1).

The parity of the decimal number of the ⑤ Gray code is the same as the parity of the number of 1 in the code word.

3. ASCII code

(1) Introduction

ASCII (American Standard Code for Information Interchange, U.S. Information Interchange Standards Codes ) is a set of computer coding systems based on the Latin alphabet, Mainly used to display modern English and other Western European languages. It is the most versatile single-byte encoding system today.

(2) An ASCII code is represented by a 8-bit binary.

Just record these, details yourself Google or Baidu bar.

4. Other Codes

Other codes, such as parity code, cyclic redundancy check code (CRC), Hamming code, QR Code, NRZ code, Huffman code, Manchester code, and so on, are recorded later when they are applied.

(b) Coding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.