Computer Knowledge-hexadecimal conversion

Source: Internet
Author: User
(1) the basic concept of the carry-in counting system sorts numeric symbols into digits in order, and counts them in a way from low to high, it is called the carry counting system. For example, we usually use the decimal system, which is short for decimal. It is counted according to the "every ten in one" principle. The carry-counting representation mainly includes three basic elements: digit, base, and bit weight. A digit refers to the position of a digit in a number. A base refers to the number of digits that can be used on each digit in a carry-in counting system, for example, in a decimal-digit counting system, the numbers available for each digit are 0, 1, 2, 3... The base number of 9 digits is 10. The bit weight refers to a fixed value. It refers to the value size represented by the number of digits in a certain carry counting system, it is equal to the number on this digit multiplied by a fixed value. This fixed value is the bit weight of this digit in this carry counting system. The numbers vary depending on their locations. For example, in the decimal place counting system, the first digit on the left of the decimal point is 100, the second digit on the left is 101, and the third digit on the left is 102 ;.... The first digit on the right of the decimal point is 10-1; the second digit on the right of the decimal point is 10-2 ;... And so on. 1. Decimal
Decimal digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. Each digital symbol determines its actual value based on its position (DIGIT) in the number, that is, the bitwise of each digit is the power of 10.
Example: (215.48) 10 = 2x102 + 1X101 + 5x10 0 + 4x10-1 + 8x10-22. Binary
Binary counting is short for binary. There are two different digital symbols: 0 and 1. Each digital symbol determines its actual value based on its position (DIGIT) in the number, that is, the bitwise of each digit is the power of 2.
Example: (11001. 01) 2 = 1 × 24 + 1 × 23 + 0 × 22 + 0 × 21 + 1 × 20 + 0 × 2-1 + 1 × 2-2 = (25.25) 103. octal
The octal counting system is abbreviated as octal. There are eight different digital symbols: 0, 1, 2, 3, 4, 5, 6, and 7. Each digital symbol determines its actual value based on its position (DIGIT) in the number, that is, the bitwise power of each digit is the power of 8.
Example: (162.4) 8 = 1x82 + 6x81 + 2x80 + 4x8-1 = (114.5) 104. hexadecimal
Hexadecimal notation (hexadecimal notation: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Each digital symbol determines its actual value based on its position (DIGIT) in the number based on "every sixteen in one, that is, the bitwise of each digit is the power of 16.
Example: (2bc. 48) 16 = 2x162 + B x 161 + C x 160 + 4x16-1 + 8x16-2 = (700.28125) 10 summarize the above four carry counting systems, they can be summarized as each counting system has a fixed base, and each digit has a different value in the base. Each counting system has its own bit right, and follow the principle of "base-to-base. (2) Conversion between carry counting systems
1. Simple Method of Binary Conversion to decimal: (10110101) 2. Write 2021222324252627 pairs (1 2 4 8 16 32 64 128) under the corresponding number from low to high) add (181) 10 after multiplication (adding red numbers)2. Conversion between different carry counting systems is essentially a base conversion. The general conversion principle is: if two rational numbers are equal, the integer and decimal parts of the two numbers must be equal. Therefore, when converting between numbers, the integers and decimals are usually converted. 1. convert non-decimal number (n-decimal number) to decimal number. The method is to expand and sum each n-decimal number according to the weight.
For example:
(10110.11) 2 = 1x24 + 0x23 + 1x22 + 1x21 + 0x20 + 1X2-1 + 1X2-2 = (22.75) 10
(125.24) 8 = 1x82 + 2x81 + 5x8 0 + 2x8-1 + 4x8-2 = (85.3125) 10
(3a8. 48) 16 = 3 × 162 + A × 161 + 8 × 160 + 4 × 16-1 + 8 × 16-2 = (936.28125) 10 2. decimal number to non-decimal number (N hexadecimal number) method: the integer part adopts the "except base number remainder method", and the decimal part adopts the "Multiplication base number integer method ".
1) decimal conversion to binary number method: the integer part adopts the "except 2 remainder method", and the decimal part adopts the "take 2 integer method ".
For example, convert decimal (123.75) 10 to binary integer part 123 to the following: remainder. decimal point
2 123 1 integer low
2 61 1
2 30 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1 integer high decimal part 0.75 conversion: decimal point. Integer 0.75
| * 2
First decimal place | 1 1.50
| 0.50
| * 2
Last decimal point | 1 1.00
00 -- zero. After the conversion is completed, 10 = (123.75) 22 is converted to the octal number in decimal format.
Method: The integer part adopts the "except the 8 remainder method", and the fractional part adopts the "take the 8 Integer method ".
For example, convert decimal (123.75) 10 to the remainder of octal.
8 | 123 | integer low
8 | 15 3 |
8 | 1 7 |
0 1 | integer high decimal point. Integer 0.75
| * 8
| 6 6.00
| 00 -- zero, switch complete
(123.75) 10 = (173.6) 83) decimal conversion to hexadecimal number method: the integer part adopts the "except 16 remainder method ", the fractional part adopts the "take 16 integer" method ". For example, convert decimal (123.75) 10 to hexadecimal remainder. decimal point
16 | 123 | integer low
16 | 7 B |
0 7 | integer high decimal point. Integer 0.75
| * 16
| C 12.0
| 0 -- zero. The conversion ends with (123.75) 10 = (7B. c) 163. Mutual conversion between non-decimal numbers 1) Conversion between Octal numbers and binary numbers
Because one octal digit is equivalent to three binary digits, to convert an octal digit to a binary digit, you only need to specify the decimal point, to the left or right, replace each octal number with the corresponding three-digit binary number. If there are less than three digits, zero complement is available. On the contrary, the binary number is converted to the corresponding octal number, which is only the inverse process of the preceding method, that is, the decimal point is used, to the left or right, replace each three digits with an octal number.
For example, convert octal (357.162) 8 to binary.
3 5 7 · 1 6 2   011101111001110010
That is, (357.162) 8 = (11101111.0011101) 2. For example, convert binary number (101011110.10110001) 2 to octal number. 101011110·101100010 5 3 6 5 4 2  (101011110.10110001) 2 = (536.542) 82) conversion between the hexadecimal number and the binary number
Because a hexadecimal number is equivalent to four binary numbers, to convert a hexadecimal number to a binary number, you only need to specify the decimal point, to the left or right, replace each hexadecimal number with the corresponding four-digit binary number. If there are less than four bits, zero complement is available. On the contrary, the binary number is converted to the corresponding hexadecimal number, which is only the inverse process of the preceding method, that is, the decimal point, to the left or right, replace the four binary numbers with the corresponding hexadecimal number.
For example, convert hexadecimal number (5ab. 8ce) 16 to binary number. 5 a B · 8 C E 010110101011100011001110That is, (5ab. 8ce) 16 = (10110101011.10001100111) 2. For example, convert binary number (1100101001011.001100101) 2 to hexadecimal number. 0001 100101001011·001100101000 1 9 4 B 3 2 8That is, (1100101001011.001100101) 2 = (194b. 328) 16

 

Related Article

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.