1) Number System
Binary is used in computers, because binary is easy to operate, easy to implement, and reliable, it provides a favorable way for logical design and saves devices. In order to facilitate the description, it is also commonly used for the abbreviation of binary when the hexadecimal notation is used.
Generally, carry counting is used, which is characterized:
(1) When n goes into one place, N indicates the number of symbols required for a single digit as the base number.
(2) The position representation means that numbers in different positions represent different values, while the unit number represents a definite value at a fixed position, the value on this fixed bit is called the right. In the computer: D7 D6 D5 D4 D3 D2 D1 D0 only has two types of 0 and 1 8 4 2 1
Ii) Digital Conversion
Conversion principle between different carry counters: the conversion between different carry Counters is based on the principle that two rational numbers, such as equal, must be equal to the integer and fractional part of the two numbers. That is to say, if the first two numbers are equal, they must still be equal after conversion.
Four-digit decimal: 10 Base numbers: 0 ~~ 9. Decimal binary: There are two bases: 0 ~~ 1. Every two to eight steps: there are eight bases: 0 ~~ 7. Every eight-in-One hexadecimal format: there are 16 bases: 0 ~~ 9, a, B, c, d, e, f (a = 10, B = 11, c = 12, D = 13, E = 14, F = 15 ), every 16th one
1. Carry count n = a n-1 * P n-1 + A N-2 * P N-2 +... + A2 * P2 + A1 * P1 + a0 * P0
2. Conversion between decimal number and p-base number
① Convert decimal to binary: convert a decimal integer to a binary integer. Generally, the remainder method is used, while the decimal part is rounded to 2. For example, convert (30) 10 to a binary number.
Convert (30) 10 to binary 2 | 30 .... 0 ---- rightmost 2 15 .... 1 2 7 .... 1 2 3 .... 1
1 .... 1 ---- leftmost percentile (30) 10 = (11110) 2 convert (30) 10 to eight, hexadecimal number 8 | 30 ...... 6 ------ rightmost 3 ------ leftmost percentile (30) 10 = (36) 8
16 | 30... 14 (e) ---- rightmost 1 ---- leftmost digit decimal number (30) 10 = (1E) 16 3. Convert P to decimal number
Convert a binary value to decimal format: multiply the last digit of the binary value by 20, and the last and second digits by 21 ,......, Until the maximum bit is multiplied by 2n, then the result of adding the product is its decimal expression.
Convert binary 11110 to decimal (11110) 2 = 1*24 + 1*23 + 1*22 + 1*21 + 0*20 = 16 + 8 + 4 + 2 + 0
= (30) 10
Convert an octal value to decimal format: multiply the last bits of the octal value by 80, and the last and second BITs by 81 ,......, Until the maximum bit is multiplied by 8n, then the result of adding the product is its decimal expression.
Convert octal 36 to decimal (36) 8 = 3*81 + 6*80 = 24 + 6 = (30) 10
Convert a hexadecimal system to decimal: multiply the last digit of the hexadecimal system by 160, and multiply the last and second digits by 161 ,......, Until the maximum bit is multiplied by 16 N, then the result of adding the product is its decimal expression.
Convert the hexadecimal 1E to the decimal (1E) 16 = 1*161 + 14*160 = 16 + 14 = (30) 10 3. Convert the binary into the octal number.
(1) convert a binary number to an octal number: For integers, each three digits of the binary number are divided into one group from the low to the high. If there are not three digits, add 0 to the left of the high position, replace each three-digit binary number with an octal number. The decimal part starts from the decimal point and is converted from left to right to each three-digit group. For example:
Convert the binary number 1101001 to the octal number (001 101 001) 2 ||| (1 5 1) 8 (1101001) 2 = (151) 8
(2) convert an octal number to a binary number: replace each octal number with a three-digit binary number. For example, convert an octal number (643.503) 8 to a binary number, then
(6 4 110 0 3) 8 | (100 101 011. 000 011) 2
(643.503) 8 = (110100011.101000011) 2 4. Conversion between binary and hexadecimal
(1) convert a binary number to a hexadecimal number: because the power of 2 is equal to 16, according to the binary and octal conversion methods, each four digits of the binary number are represented by a hexadecimal number. The integer part is converted from the right to the left to a group of four decimal points, the decimal part is converted from the decimal point to the right by a group of four digits. (2) convert a hexadecimal number to a binary number. If a hexadecimal number is converted to a binary number, each hexadecimal number must be represented by four binary numbers, to complete the conversion.
For example, to convert (163.5b) 16 to a binary number, (1 6 3. 5 B) 16 | (0001 0110 0011. 0101 1011) 2 (163.5b) 16 = (101100011.01011011) 2