Base of Binary Conversion

Time:2019-9-11

Basic knowledge

Decimal system
The cardinal number is 10, every 10 enters 1. In decimal system, a total of 10 different digital symbols are used. When these symbols are in different positions, their weights are different.

Binary system
The cardinal number is 2, every 2 enters 1. In binary system, two symbols, 0 and 1, are used.

Octal number system
Base number is 8, every 8 into 1. Eight different symbols are used in octal system. Their conversion relationship with binary system is as follows:
0:000 1:001 2:010 3:011 4:100 5:101 6:110 7:111

Hexadecimal
The cardinal number is 16, every 16 enters 1. Hexadecimal uses 16 different symbols, and their conversion to binary is as follows:
0:0000 1:0001 2:0010 3:0011 4:0100 5:0101 6:0110 7:0111 8:1000 9:1001 A:1010 B:1011 C:1100 D:1101 E:1110 F:1111

System conversion to decimal system

Binary to decimal
Example: Convert binary number 101.01 to decimal number
(101.01)2 = 1×22 + 0×21 + 1×20 + 0×2-1 + 1×2-2 = (5.25)10

Octal to decimal
Example: Convert octal number 12.6 to decimal number
(12.6)8 = 1×81 + 2×80 + 6×8-1 = (10.75)10

Hexadecimal to decimal
Example: Convert hexadecimal number 2AB.6 to decimal number:
(2AB.6)16 = 2×162 + 10×161 + 11×160 + 6×16-1 = (683.375)10

switching sites

Octal to binary
Rule: In order, every octal number is rewritten to the equivalent 3-bit binary number, the order is unchanged.
Example: (17.36) 8 = 001 111.011 110) 2 = 1111.01111) 2

Hexadecimal to binary
Rule: Every hexadecimal number is rewritten to an equivalent 4-digit binary number in the same order.
Example: (3A8C.D6) 16 = (0011 1010 1000 1100.1101 0110) 2 = (11101010001100.1101011) 2

Conversion of decimal integers into binary integers

Rule: Except for two, till the quotient is zero, inverted.
Example: Convert decimal 86 to binary
2 | 86…… 0
2 | 43…… 1
2 | 21…… 1
2 | 10…… 0
2 | 5 …… 1
2 | 2 …… 0
2 | 1 …… 1
Results: (86) 10 = 1010110) 2

Decimal decimal to binary decimal

Rule: Multiply two and take the whole, until the decimal part is zero or given accuracy, in order.
Example: Convert decimal number 0.875 to binary number
0.875
× 2
1.75
× 2
1.5
×2
1.0
Results: (0.875) 10 = 0.111) 2

Convert to octal

Binary to octal
The integer part starts with the lowest significant bit and is composed of three bits. When the highest significant bit is less than three bits, it is complemented by zero. Each group can be converted into an octal value, and the conversion is an octal integer.
The decimal part starts with the highest significant bit, and is composed of three bits. When the lowest significant bit is less than three bits, it is filled with zero. Each group can be converted into an octal value. The conversion is an octal decimal.
Example: (11001111.01111) 2 = 11 001 111.011 110) 2 = 317.36 8

Hexadecimal to octal
Firstly, hexadecimal system is converted into binary system by 1 to 4 method, and then binary system is converted into 8 system by 3 to 1 method.
Example: (1CA) 16 = (000111001010) 2 = (712) 8
Explanation: High zero before decimal point and low zero after decimal point can be removed.

Decimal octal system
Method 1: Divide 8 to get the remainder.
Example: Convert decimal number 115 to octal number
8| 115…… 3
8| 14 …… 6
8| 1 …… 1
Results: (115) 10 = 163) 8
Method 2: First, the decimal binary system is adopted, and then the binary system is converted into octal system.
Example: (115) 10 = 1110011) 2 = 163) 8

Convert to hexadecimal

Binary to hexadecimal
The integer part starts with the lowest significant bit and is grouped with four bits. When the highest significant bit is less than four bits, it is complemented with zero. Each group can be converted into a hexadecimal value, and the conversion is completed as a hexadecimal integer.
The decimal part begins with the highest significant bit and is grouped with four bits. When the lowest significant bit is less than four bits, it is filled with zero. Each group can be converted into a hexadecimal value, and the conversion is completed as a hexadecimal decimal.
Example: (11001111.01111) 2 = 1100 1111.0111 1000) 2 = CF.78) 16

Octal to hexadecimal
First the octal system is converted into binary system, and then the binary system is converted into hexadecimal system.
Example: (712) 8 = (111001010) 2 = (1CA) 16

Decimal system into hexadecimal system

Method 1: The method of dividing by 16 was used.
Example: Convert decimal number 115 to octal number
16| 115…… 3
16| 7 …… 7
Results: (115) 10 = 73) 16

Method 2: First convert decimal system into binary system, then binary system into hexadecimal system.
Example: (115) 10 = 1110011) 2 = 73) 16