-
The representation of numbers in computers - binary.
1 Operations on binary numbers.
Electronic computers generally use binary numbers. Binary numbers have only two basic digits, 0 and 1, which are easy to implement in electrical components.
The formula for the operation of binary numbers:
2.Conversion between decimal and binary.
1) Convert decimal numbers to binary.
When converting a decimal integer to a binary integer, just divide it by 2 again and again, and the resulting remainder is read from the last remainder) is the number represented in binary.
2) Binary numbers are converted to decimal numbers.
Converts the integer of a binary number to a decimal number, as long as the weighting is placed.
Example: 11011 = 1 * 24 (2 to the 4th power) + 1 * 23 (2 to the 3rd power) + 0 * 22 (2 to the 2nd power) + 1 * 21 (2 to the 1st power) + 1 * 20 (2 to the 0th power) = 27
3 Conversion of decimal numbers.
Binary numbers and octal numbers are swapped: when the binary number is converted into an octal number, you only need to start from the decimal point position, divide every three digits of binary to the left or right into a group (if there are less than three digits, you can add 0), and then write the octal number corresponding to each group of binary numbers.
Example: Replace the binary number ** with an octal number:
That is, the binary number ** is replaced by an octal number is (. Conversely, by representing each octal number as a three-digit binary number, the conversion of octal and binary numbers can be completed.
Binary numbers and hexadecimal numbers are interchanged: when converting binary numbers to hexadecimal numbers, you only need to start from the decimal point position, divide every four digits of binary to the left or right into a group (if there are less than four digits, you can add 0), and then write out the hexadecimal number corresponding to each group of binary numbers.
Example: Replace the binary number ** with a hexadecimal number:
6 e 6 d
That is, the binary number ** is replaced by a hexadecimal number (. Conversely, by representing each hexadecimal number as a three-digit binary number, the conversion of hexadecimal and binary numbers can be completed.
Conversion of octal numbers, hexadecimal numbers, and decimal numbers: When converting these three numbers, you can use binary numbers as a medium, first convert the algebraic numbers into binary numbers, and then convert the binary numbers into the number system form that needs to be converted.
-
Binary to decimal.
The weight of the 0th digit of a binary number is 2 to the power of 0, and the weight of the 1st digit is to the power of 2......
For example, there is a binary number: 0110 0100, which is converted to decimal as: Below is the vertical type:
0110 0100 to decimal.
Bit 0 0 x 2 0 = 0
1st digit 0 x 2 1 = 0
2nd bit 1 x 2 2 = 4
3rd digit 0 x 2 3 = 0
4th digit 0 x 2 4 = 0
5th bit 1 x 2 5 = 32
6th bit 1 x 2 6 = 64
Bit 7 0 x 2 7 = 0
0110 0100)b=(100)d
Octadecimal to decimal.
The octal system is every 8 into 1.
Octal numbers use the eight numbers 0 7 to express a number.
The 0th digit of an octal number has a weight of 8 to the power of 0, the 1st digit has a weight of 8 to the 1st power, and the 2nd digit has a weight of 8 to the 2nd power......
So, there is an octal number: 1507, which is converted to decimal as:
Vertically: 1507 to decimal.
Digit 0 7 x 8 0 = 7
1st digit 0 x 8 1 = 0
2nd digit 5 x 8 2 = 320
3rd digit 1 x 8 3 = 512
1507)o=(839)d
In the same way, we can also use the horizontal direct calculation:
7 x 8 0 + 0 x 8 1 + 5 x 8 2 + 1 x 8 3 = (839)d The result is that the octal number 1507 is converted to a decimal number 839
Hexadecimal is converted to decimal.
Decimal is converted to binary, octal, hexadecimal.
1.The integer part divides by r and takes the remainder.
Example: (125)d=(1111101)b
Note: The last remainder in the remainder is the highest digit, and the first remainder is the lowest digit, in order from high to low.
2.The decimal part is multiplied by r and rounded up.
Example: (x 2.)
The integer part of 0 is the high position).
x 2 integer part 1 is the low bit).
-
Formula: Converted number = sum of pre-conversion position weights.
-
There are two ways to convert between octal and hexadecimal, which are as follows:
The octal system has 0 7 a total of 8 numbers, the base is 8, the addition operation is eight into one, and the subtraction operation is borrowed as eight. For example, numbers are all valid octals.
In hexadecimal, a is used to represent 10, b is used to represent 11, c is represented by 12, d is represented by 13, e represents 14, and f represents 15, so there are 16 numbers with 0 f, and the base number is 16, and 16 is advanced into 1 when adding and 16 is borrowed for subtraction. For example, the numbers , a, d, f, 419, ea a3, bc00 are all valid hexadecimals.
Method 1:
1. The octal system is converted into binary, and the method is that the octal number is obtained by dividing the hunger 2 remainder method, and each octal is 3 binaries, and the leftmost zero is added when it is insufficient.
2. Binary is converted to hexadecimal, and the method is to add 4-digit binary numbers to obtain 1-digit octal numbers by adding weights.
Method 2:
1. The octal system is converted into the decimal system, and the method is to get the decimal number by weighting and adding the decimal number.
2. Convert the decimal system into the hexadecimal system, and the method is to convert the decimal system to the octal system according to the division of 8 to take the remainder, and the straight base excavation is returned to the quotient to 0.
-
Decimal to Hexadecimal:
Convert decimal to binary first, and then convert binary to hexadecimal binary to hexadecimal: the four bits of binary are converted to one digit of hexadecimal, the integer digits are advanced from the lowest bit to the left for operation, and the decimal place is advanced from right to left.
Decimal integers are converted to binary integers"Divide by 2 and take the remainder and arrange them in reverse order", decimal decimal to binary decimal is "multiplied by two rounded, arranged in order".
-
1. Binary to decimal system.
The binary number 00111 has a bit weight from low to high power, which is 2 to the power of 0, to the power of 1, to the power of 2, to the power of 3, to the power of 4, and to the power of 16.
Once you understand the cardinality and bit weights of binary counting, you can perform the number system conversion. How do I convert 00111 to a decimal count? The conversion is as simple as multiplying each binary number from high to low bit, multiplying each digit weight, and summing it.
00111 (binary) = 0 * 2 (5-1) +0 * 2 (4-1) +1 * 2 (3-1) +1 * 2 (2-1) +1 * 2 (1-1).
7 (decimal).
2. Convert decimal to binary.
The conversion of decimal integers to binary integers can be done by "dividing by 2 to take the remainder, and output in reverse order", the specific conversion process is to remove a decimal number with 2 to get the quotient and remainder, and then use 2 to remove the quotient, and then get the quotient and remainder, and the cycle repeats until the quotient is 0. If the decimal decimal is converted to a binary decimal place, "multiply by 2 to round up, and output sequentially". The conversion process is shown in the following figure:
3. Conversion between binary and octal.
Binary to round spike octal: take the three-in-one method, that is, from the decimal point of the binary as the demarcation point, to the left (to the right) every three digits into one, and then add the binary of the three orange Mingbu according to the weight, and then, in order, the position of the decimal point remains the same, and the number obtained is the octal number we seek.
If you take three digits to the left (right) and get the highest (lowest) digit, if you can't make up three digits, you can add 0 to the leftmost (rightmost) digit of the decimal point, that is, the highest digit (lowest digit) of the whole number, to make up three digits.
4. Octadecimal to binary: take one point and three methods, that is, decompose a octal number into a three-digit binary number, and use the three-digit binary to add the weight to make up the octal number, and the decimal point position remains the same.
5. Conversion between binary and hexadecimal.
Binary to hexadecimal: take the four-in-one method, that is, from the decimal point of the binary as the demarcation point, to the left (to the right) every four digits into a bit, and then add the four binaries according to the weight, and then, in order, the position of the decimal point remains the same, and the number obtained is the hexadecimal number we seek.
If you take four digits to the left (right) and get the highest (lowest) digit, if you can't make up four digits, you can add 0 to the leftmost (rightmost) digit of the decimal point, that is, the highest digit (lowest digit) of the whole number, to make up four digits.
6. Hexadecimal to binary: take a four-point method, that is, decompose a hexadecimal number into a four-digit binary number, and use the four-digit binary to add the weight to make up the hexadecimal number, and the decimal place remains the same.
7. Between decimal and octal, between decimal and hexadecimal, the decimal system is first converted to binary, and then converted to octal or hexadecimal.
-
1. Decimal to binary.
The method is: decimal number divided by 2 remainder method, that is, the decimal number is divided by 2, the remainder is the number on the weight, the obtained quotient continues to divide by 2, and this step continues to operate down until the quotient is 0.
2. Binary to decimal.
The method is: add the binary numbers according to the weight to get the decimal number.
3. Binary to octal.
The method is as follows: 3-digit binary numbers are added to obtain 1-digit octal numbers by adding weights. (Note that the conversion of 3-digit binary to octal is from right to left, and 0 is added when it is insufficient).
4. Octadecimal to binary.
The method is: the number on each bit of the octal number is converted into a three-digit two-digit base system, and the order is from right to left.
5. Binary to hexadecimal.
The method is similar to the binary to octal method, the octal is to take three in one, and the hexadecimal is to take four in one. (Note that the conversion of 4-bit binary to hexadecimal is from right to left, and 0 is added when it is insufficient).
6. Hexadecimal to binary.
The method is as follows: the number on each bit of the hexadecimal number is converted to a four-digit binary, in order from right to left.
-
The binary octal, decimal and hexadecimal conversion tables are as follows:
Decimal: It is composed of nine numbers from 0 to 9 and cannot start with 0. Binary: Consists of two numbers, 0 and 1.
Octadecimal: Consists of 0-7 numbers, and in order to distinguish them from other decimal numbers, they all start with 0.
Hexadecimal: Consists of 0-9 and a-f. To distinguish it from other numbers, it always starts with 0x.
Decimal is converted to binary, octal, hexadecimal.
Integer conversion. Decimal to binary.
The principle of decimal to binary conversion: divide by 2 and take the remainder in reverse until the quotient is terminated at 0.
Specific method: keep the part of the integer obtained by dividing a decimal number by 2 as the dividend when dividing by 2 for the second time, write down the remainder obtained in turn, repeat the above steps until the integer part is 0, and finally output all the obtained remainders in reverse order, which is the binary number corresponding to the decimal system.
Decimal to octal.
Conversion principle: Divide by 8 and take the remainder in reverse until the quotient is terminated at 0.
For example, convert the decimal number 796 to an octal number: divide 796 by 8 to get the first remainder as 4, divide by 8 to get the integer part 99 as the second dividend, and repeat the above steps until the final integer part is 0.
All the remaining numbers that will be obtained are output in reverse order. It is: 796 >1434.
Decimal to hexadecimal.
Conversion principle: divide by 16 and take the remainder in reverse until the quotient is terminated at 0. The specific steps are the same as binary and octal, and the hexadecimal number can be obtained by repeating the above method.
For example: the decimal number 796 is converted to a hexadecimal number. That is:
796â>31că
Note that hexadecimal numbers are composed of 0-9 and a-f (or a-f), a is equivalent to 10 in decimal, b is equivalent to 11, and so on, f is equivalent to 15, and the remainder of 12 obtained in the above example is c in hexadecimal.
The principle of the integer part conversion of the base system is to divide the base number and take the remainder, and output it in reverse order.
Fractional part conversion.
Decimal to binary principle: Decimal decimal to binary decimal conversion adopts the method of "multiplying 2 by integer, sequential output".
Decimal to octal principle: Decimal decimal to octal decimal conversion adopts the method of "multiplying 8 by rounding and sequential output".
Decimal to Hexadecimal principle: Decimal decimal to hexadecimal to convert to hexadecimal decimal using the "multiply 16 round, sequential output" method.
Octadecimal and hexadecimal converted to binary.
The principle of converting octal numbers to binary: one digit of an octal number is three digits of a binary number.
Hexadecimal number to binary principle: one digit of a hexadecimal number is four digits of a binary number.
Conversion between octal and hexadecimal.
The conversion between the two can be done with the help of decimal or binary, which can be converted from octal to decimal or binary and then to hexadecimal. This is achieved through indirect conversion.
Binary numbers. Writing is long, error-prone, and hard to remember, while the decimal system. >>>More
Convert decimal integers to binary numbers.
The divide by 2 reverse remainder method is adopted: >>>More
If it's a method, I can give you a natural language description of how the decimal integer part n can be converted to binary as follows: >>>More
First of all, you need to convert the number into two parts: an integer and a decimal. Integer part: divide by two and take the remainder inverted: >>>More