Table of contents
1. Necessary knowledge for base conversion:
2. Convert between binary, octal and hexadecimal
2.4 Convert hexadecimal to binary
3. Convert between binary and decimal
4. Convert between octal and decimal
4.1 Octal to decimal (indirect conversion, direct conversion)
5. Convert between hexadecimal and decimal
5.1 Convert hexadecimal to decimal
5.2 Convert decimal to hexadecimal
6.1 Conversion between binary decimals and decimal decimals
6.2 Convert binary decimal to octal
6.3 Binary decimal to hexadecimal
1. Necessary knowledge for base conversion:
1.1 Binary enters 1 every 2, octal enters 1 every 8, decimal enters 1 every 10, hexadecimal enters 1 every 16
Note: Since the hexadecimal number exceeds 10, when the number is represented by two digits in hexadecimal, it will cause digital confusion, so we use A, B, C, D, E, F to represent 10, 11, 12, 13 , 14, 15
1.2 In order to distinguish binary, octal, decimal, and hexadecimal, we usually add letters after the numbers to distinguish
Binary is Binary, abbreviated as B
Octal is Octal, abbreviated as O
Decimal is Decimal, abbreviated as D
Hexadecimal is Hexadecimal, abbreviated as H
2. Convert between binary, octal and hexadecimal
Knowledge that must be understood:
3 binary numbers can represent an octal number, and conversely, an octal number can represent 3 binary numbers.
Example: converting binary number 111 to octal number is 7, and converting octal number 7 to binary number is 111
4 binary numbers represent a hexadecimal number, ditto...
Example: convert the binary number 1111 to hexadecimal number 15, same as above...
2.1 Convert binary to octal
Method: Convert 3-digit binary to 1-digit octal (three digits are selected from right to left, and the leftmost group is not enough for three digits to fill with 0)
Conversion process:
2.2 Octal to binary
Method: A number in octal represents 3 numbers in binary
Conversion process:
2.3 Binary to hexadecimal
Method: 4 binary numbers represent 1 hexadecimal number
Conversion process:
2.4 Convert hexadecimal to binary
Method: 1-digit hexadecimal to 4-digit binary
Conversion process:
3. Convert between binary and decimal
3.1 Convert binary to decimal
Method: Expansion by weight
Method concept: Take the binary number 101 as an example, the rightmost 1 means the weight is 0, the middle 0 means the weight is 1, the leftmost weight is 2, and then it is a binary number, so multiply each digit by 2 The power (power size weight digit size) bit weight starts from 0, and the size increases by 1 from right to left
Handwritten picture explanation:
3.2 Convert decimal to binary
Method: short division
Motto: Divide by two and take the remainder, arrange in reverse order
Conversion process:
4. Convert between octal and decimal
4.1 Octal to decimal (indirect conversion, direct conversion)
Method 1: Indirect conversion
First convert octal to binary, then convert binary to decimal
The "4 2 1" method can be used to convert octal to binary. Since it is composed of 3 binary numbers, it can represent a maximum of 7 (111), which means that an octal number represents 3 binary numbers.
Method Two: Direct Conversion
(divide eight and take remainder) same as (divide two and take remainder)
The two methods are answered as follows:
4.2 Convert decimal to octal
Method: divide by eight and take the remainder, arrange in reverse order
Conversion process:
5. Convert between hexadecimal and decimal
5.1 Convert hexadecimal to decimal
Method: expand by weight (same as binary)
Conversion process:
5.2 Convert decimal to hexadecimal
Method: divide by sixteen and take the remainder, arrange in reverse order
Conversion example:
6. Decimal part conversion
6.1 Conversion between binary decimals and decimal decimals
Method: The integer part is still expanded according to the weight, and the decimal part is divided by 2, 4, 8 from left to right...
Conversion example (two to ten):
Conversion example (ten to two)
Method: Integer part "divide by two and take remainder, sort in reverse order", fractional part "multiply by two and round up, sort forward"
6.2 Convert binary decimal to octal
Method: Integer part "4 2 1 method" fills in front with 0 for less than three digits, and fills with 0 for decimal part "4 2 1 method" not enough for three digits
Note: When calculating, the bit weights are all added 1 from right to left
Conversion process:
6.3 Binary decimal to hexadecimal
Method: Similar to (two to eight)
Note: Similar to (two to eight)
Conversion process:
7. Summary
Integer part:
Two, eight, hexadecimal to decimal - (according to the right expansion method)
Decimal to binary, octal, hexadecimal - (dividing the remainder of n, arranged in reverse order) - n indicates how many bases
decimal part:
Two, eight, hexadecimal decimal to decimal - (divided by the power of n's bit weight) the bit weight is 1, increasing by 1 from left to right
Decimal to binary, octal, hexadecimal - (Multiply by n and round up, forward arrangement)
If you think Xiaoyu base conversion is good, I look forward to your one-click triple link! ! !
If you have any questions or mistakes, remember to tell me, and I will reply in time.