one or 10 conversion between binary and binary
(1) Decimal conversion to binary, divided into integers and fractional parts
① Integer Part
Methods: In addition to the 2 method, that is, each time the integer part divided by 2, the remainder is the number of the right, and the quotient continues to divide by 2, the remainder is the number of the last bit, this step continues until the quotient is 0, the last reading, from the last remainder read, until the first remainder. Here are some examples:
Example: Converting a decimal 168 to a binary
The result is that the decimal 168 is converted to binary, (10101000) 2
Analysis: The first step: Divide 168 by 2, quotient 84, and the remainder to 0.
Step two: Divide quotient 84 by 2 and quotient 42 to 0.
The third step is to divide quotient 42 by 2 and quotient 21 to 0.
Fourth step: Divide quotient 21 by 2 and quotient 10 to 1.
Fifth step: Divide quotient 10 by 2 and quotient 5 to 0.
Sixth step: Divide quotient 5 by 2 and quotient 2 to 1.
Seventh step: Divide quotient 2 by 2 and quotient 1 to 0.
The eighth step is to divide quotient 1 by 2 and quotient 0 to 1.
nineth Step: The Reading, because the last one is after several times divided by 2 to get, so it is the highest, read the number from the last remainder read forward, that is 10101000
(2) Number of decimal parts
Method: Multiply by 2 rounding method, the fractional part is multiplied by 2, then take the integer part, the remaining fractional part continues to multiply by 2, then takes the integer part, the remaining fractional part is multiplied by 2, has been taken to the fractional part
is zero. If you can never be zero, just as the decimal number of rounding, as required to retain how many decimal places, according to the following one is 0 or 1, trade-offs, if it is zero, discard, if it is 1, into a bit. In other words, 0 shekels 1. The readings are to be read from the preceding integers to the following integers, for example:
Example 1: Converting 0.125 to binary
Result: Convert 0.125 to Binary (0.001) 2
Analysis: The first step: Multiply 0.125 by 2, get 0.25, then the whole part is divided into 0, the number part is divided into 0.25;
The second step: the number of parts 0.25 times 2, 0.5, then the whole part of 0, the number of parts divided into 0.5;
The third step: the number of parts 0.5 times 2, 1.0, then the whole part of 1, the number of parts divided into 0.0;
The Fourth step: Reading, reading from the first, reading to the last one, that is, 0.001.
Example 2, converting 0.45 to binary (reserved to fourth decimal place)
as you can see from the above steps, when the fifth time we do multiplication, The result is 0.4, then the fractional part continues to multiply by 2, 0.8, 0.8 and multiplied by 2, to 1.6 this has been riding down, the last possible to get a fractional part of zero, so this time had to learn the method of decimal rounding, but the binary system only 0 and 12, so it appears 0 1 into. This is also the computer in the conversion will produce errors, but because of the number of reserved bits, high precision, so it can be ignored.
Well, we can conclude that converting 0.45 to binary restriction equals 0.0111.
The method described above is the conversion of decimal to binary method, it is important to note that:
1) Decimal conversion to binary, need to be divided into integers and two parts of the fractional conversion
2) When converting integers, the use of the addition of 2 to the remainder method, and the conversion of decimals, with the use of 2 rounding method
3) Note the direction of their readings
so we can derive from the above method that the decimal number 168.125 is converted to binary 10101000.001, or the decimal number is converted to a binary number of approximately equal to 10101000.0111.
(3) binary conversion to decimal without integer and fractional parts
methods: By weighted addition method, the number of binary each bit is multiplied by the right, then the sum is the decimal number. Example
converts a binary number 101.101 to a decimal number.
results: (101.101) 2= (5.625)
in doing binary conversions to decimal, you need to be aware that:
1) To know the weights of each bit in binary
2) to be able to find out the value of each bit
two or two conversion between binary and octal
first, we need to understand a mathematical relationship, that is, 23=8,24=16, while octal and hex are used in this
derived from the relationship, that is, a three-bit binary representation of an octal, with a four-bit binary representation of a hexadecimal number.
Next, remember 4 numbers 8, 4, 2, 1 (23=8, 22=4, 21=2, 20=1). Now let's practice the conversion between binary and octal.
(1) binary into octal
methods: Take the Triad method, that is, from the decimal point of the binary point, to the left (right) every three bits taken into one, and then the three-bit binary by the right to add, the number is a eight-bit binary number, and then, in order to arrange, the position of the decimal point unchanged, the number is the octal number we asked for If you take three bits to the left (right) and take the highest (lowest) bit, if you cannot make up three bits, you can add 0 to the leftmost (rightmost) of the decimal point, the highest bit of the integer (the lowest bit), and fill three bits. Example
① converting binary number 101110.101 to octal
Get results: convert 101110.101 to octal to 56.5
② converting binary number 1101.1 to octal
Get results: convert 1101.1 to octal to 15.4
(2) converting octal into binary
method: Take a three-way, will be a octal number decomposition into three-bit binary number, with three-bit binary right add to the octal number, the decimal place as usual. Example:
① converting octal number 67.54 to binary
Therefore, the octal number 67.54 is converted to a binary number of 110111.101100, which is 110111.1011
As you can see from the above question, the calculation of the octal binary is converted into binary
first, the octal is expanded from left to right, each bit to three bits, and the decimal position is unchanged .
then, by each expansion as 22,21,20 (i.e. 4, 2, 1) three bits to do dine, that is ax22+ bx21 +cx20= the number of bits (a=1 or a=0,b=1 or b=0,c=1 or c=0), the ABC arrangement is the binary number of that bit
Next, convert each bit to a binary number in the order listed
Finally, the octal binary is converted into a binary number.
The above method is the binary and octal interchange, you need to pay attention to when doing the problem is
1) The interchange between them is with a three-bit conversion, which differs from binary to decimal conversion
2) When you do add 0 and go to 0, pay attention to the left of the decimal point or the right side of the decimal point (that is, the highest number of integers and decimal places) to add 0 or 0, otherwise it will produce an error
three or two binary vs. hexadecimal conversions
method: Similar to binary and octal conversions, is only a (16) and four-bit (binary) conversion, the following specific explanation
(1) binary conversion to hexadecimal
methods: Take four-in-one method, that is, from the decimal point of the binary to the point, to the left (right) every four bits, and then the four-bit binary right added, the number is a 16-bit binary number, and then, in order, the position of the decimal point is unchanged, the number is the hexadecimal number we ask for. If you take four bits to the left (right) and take the highest (lowest) bit, if you cannot make up four bits, you can add 0 to the leftmost (rightmost) of the decimal point, the highest bit of the integer (the lowest bit), and fill four bits.
① Example: Converting binary 11101001.1011 to hexadecimal
Get results: Convert binary 11101001.1011 to 16 binary to e9.b
② Example: converting 101011.101 to hexadecimal
so get the result: Convert binary 101011.101 to 16 binary to 2B.A
(2) Convert 16 binary to binary
method: Take a four-way, will be a hexadecimal number decomposition into four-bit binary number, with four-bit binary right add to the hexadecimal number, the decimal place as usual.
① converting hex 6e.2 to binary number
so get the result: Convert the hexadecimal 6e.2 to binary 01101110.0010 or 110110.001
four or eight binary vs. hexadecimal conversions
methods: Generally cannot be converted directly to each other, generally, octal (or hexadecimal) is converted to binary, and then the binary is converted to 16 (or octal), the decimal place is unchanged. Then the corresponding conversion please refer to the binary and octal conversions above and the binary and hex
five or eight binary and decimal conversions
(1) octal into decimal
methods: By weighted addition method, the number of octet per bit is multiplied by the right, then the sum is the decimal number.
Example: ① converting octal number 67.35 to decimal
(2) decimal conversion to octal
There are two ways to convert decimal into octal:
1) Indirect method: Convert decimal to binary first, then convert binary into octal
2) Direct method: As we have said before, the octal system is derived from binary, so we can use the decimal conversion to binary similar method, or integer part of the conversion and fractional part of the conversion, the following specific explanation:
① Integer Part
Methods: In addition to the 8 method, that is, each time the integer part divided by 8, the remainder is the number of the right, and the quotient continues to divide by 8, the remainder is the number of the last bit, this step has been continued until the quotient is 0, the last reading, from the last remainder, up to the front of a remainder.
② small number of parts
methods: By 8 Rounding method, the fractional part is multiplied by 8, then take the integer part, the remaining fractional part continues to multiply by 8, and then take the integer part, the remainder of the fractional part is multiplied by 8, until the fractional part is zero. If it can never be zero, just as the decimal number of rounding, the provisional name is called 3 4 in.
Example: Converting a decimal number of 796.703125 to an octal number
Solution: First divide this number into integer part 796 and decimal part 0.703125
Integer Part
number of decimal parts
So, get the result decimal 796.703125 convert octal to 1434.55
the above method can be verified, you can first convert the decimal, and then convert to eight binary
Conversion between binary octal decimal hexadecimal