First, the conversion between decimal and binary (1) decimal to binary, is divided into an integer part and fractional part ① integral part of the way: In addition to taking over France 2, which will be integral parts of each divided by 2, for the remainder of Right the number, but to continue to divide by 2, the remainder a bit further to the right of the number, this step has been to continue until the business is 0 until the time the last reading, the remainder from the last time, has been to the top of the a remainder. The following are examples:
Example: 168 decimal to binary conversion
The outcome will be converted to binary decimal 168, (10101000) 2
Analysis: The first step would be 168 divided by 2, Business 84, the remainder is 0.
The second step will be 84 divided by 2 operators, commercial number 42 I 0.
The third step will be 42 divided by 2 operators, the number of operators more than 21 to 0.
The fourth step would be 21 divided by 2 operators, the number of business more than 10 to 1.
The fifth step, the business 10 divided by 2, Business 5 the remainder is 0.
The sixth step, the business 5 divided by 2, remainder is 1 business 2.
Seventh step, the Business 2 divided by 2, Business 1, the remainder is 0.
Step eight would be 1 divided by 2 operators, business 0 remainder of 1.
Ninth step of reading, because the last one is only obtained after repeated divided by 2, so it is the highest place, reading the remainder of the word forward from the last time, that is, 10101000
(2) fractional method: Take 2 to take the whole law, be the fractional part multiplied by 2, then take the integer part, the remaining fractional part of the continuing multiplied by 2, then take the integer part, then multiplied by the fractional part of the remaining 2 fractional part of zero has been taken to date. If you can never be zero, the decimal rounding with the same number of decimal places as required retention time, under the back of a is 0 or 1, choice, if it is zero, give it up, if it is 1, to enter one. In other words, 0 round 1 entry. Reading back from the front of the integer read integer, the following example:
Example 1: The conversion to binary 0.125
Outcome: to convert a binary 0.125 (0.001) 2
Analysis: The first step would be 0.125 multiplied by 2, was 0.25, the integer part is 0, the fractional part 0.25;
The second step, the fractional part of 0.25 multiplied by 2, 0.5, 0 is an integer part, fractional part is 0.5;
The third step, the fractional part will be multiplied by 2, 0.5, 1.0, then the integer part of 1, the fractional part of 0.0;
The fourth step, reading, starting from the first reading, read the last one, that is, 0.001.
Example 2, the 0.45 is converted to binary (reserved to the fourth decimal point)
We can see from the above steps, when the fifth time to do multiplication, and the result is 0.4, then multiplied by the fractional part to 2, was 0.8,0.8 then multiplied by 2, to 1.6 this has been by it and eventually impossible be the fractional part of zero, so this time had to learn the method of rounding decimal, but binary only 0 and 1, 2, and so it was round 1 into 0. This is also the computer will produce errors in the conversion, but because the median number of reservations, high precision, it can be ignored.
So, we can conclude that the results will be converted to a binary equivalent to about 0.45 0.0111
Described above is converted to decimal to binary approach, need to note that:
1) decimal to binary, to be divided into two parts respectively, integer and fractional conversion
2) When converting an integer, with the addition of more than 2 out of law and the conversion decimal time, using a rounding method by 2
3) Note the direction of their reading, therefore, we approach from above, we can draw a decimal number converted to binary as 10,101,000.001 168.125, or 168.45 is converted to a binary decimal number about equal to 10101000.0111.
(3) is converted to decimal, regardless of the binary integer and fractional method: the right to add according to law, be multiplied by the binary number of each on the right, then the sum of which is a decimal number. Example will convert a binary number to decimal number 101.101.
Outcome: (101.101) 2 = (5.625) 10
We are doing the binary into decimal to note that
1) The right to know the value of each binary
2) to be able to calculate the value of each (Note: the weight behind the decimal point is 2 (-1), 2 (-2), etc.).
Decimal octal and hexadecimal transfer of principles with the principle of transfer as binary.