Current location - Training Enrollment Network - Mathematics courses - How to convert binary numbers into hexadecimal numbers?
How to convert binary numbers into hexadecimal numbers?
1, binary to hexadecimal method:

Take the four-in-one method, that is, take the binary decimal point as the dividing point, take one bit for every four bits to the left (right), and then add the four bits of the binary according to the weight to get a binary number of 16 bits. Then, in order, the position of the decimal point remains unchanged, and the number obtained is the hexadecimal number we seek. If four digits are taken from the left (right), the highest (lowest) digit is taken. If four digits cannot be filled in, you can add 0 to the left (rightmost) decimal point, that is, the highest (lowest) digit of the integer to fill in four digits.

(1) Example: Convert binary11001.1kloc-0/to hexadecimal.

Get the result: convert binary11101.10/into hexadecimal E9. B

(2) Example: convert1011.1kloc-0/into hexadecimal.

Get the result: convert binary10101.101into hexadecimal 2B. A

2, the method of converting hexadecimal to binary:

Take the quartering method as an example, that is, a hexadecimal number is decomposed into four binary numbers, and the four binary numbers are weighted and added to form a hexadecimal number, and the decimal point position remains unchanged.

(1) Example: Convert hexadecimal 6E.2 into binary number.

The result is: converting hexadecimal 6E.2 into binary is 011010.05438+00, that is,1100.50086.000000000005

Attached is a comparison table of decimal, binary and hexadecimal conversion.

Extended data:

Conversion between binary and octal;

First of all, we need to understand a mathematical relationship, that is, 2 3 = 8, 2 4 =16. Octal and hexadecimal are derived from this relationship, that is, three binary numbers represent an octal number and four binary numbers represent a hexadecimal number.

Then, remember four numbers 8,4,2,1(2 3 = 8,2 2 = 4,21= 2,2 0 =1). Now let's practice the conversion between binary and octal.

1, binary to octal method:

Take the three-in-one method, that is, take the binary decimal point as the dividing point, take one bit from every three digits to the left (right), and then add the three digits of the binary by weight to get an eight-digit binary number. Then, in order, the position of the decimal point remains unchanged, and the number obtained is the octal number we seek. If the left (right) takes three digits and the highest (lowest) digit, if the three digits cannot be filled, you can add 0 after the leftmost (rightmost) decimal point, that is, the highest (lowest) digit of the integer to fill the three digits.

(1) Example: Convert the binary number10/kloc-0.101to octal.

Get the result: convert10110.101into octal to 56.5.

(2) Example: Convert the binary number11kloc-0/.1into octal.

The result is: converting1101.1into octal is 15.4.

2. Convert octal to binary

Methods: An octal number was divided by three binary numbers, and the three binary numbers were added by weight to form an octal number, and the decimal point position remained unchanged.

(1) Example: Convert the octal number 67.54 into binary.

Convert the octal number 67.54 into binary number111.10100, that is11.

As can be seen from the above problems, to calculate the conversion from octal to binary, first, octal is expanded from left to right into three digits, and the decimal point position remains unchanged; Then, each bit is expanded into three bits (22,265,438+0,20 (that is, 4,2, 1) to make up the number, that is, a× 22+b× 265,438+0+c× 20 = the number on this bit (a= 1) Finally, we get numbers from octal to binary.

References:

Baidu Encyclopedia-Binary Conversion