Help you quickly understand the mental arithmetic binary decimal turn. (Own exercises, will understand, will not you cut me)

table of Contents:

1. memorize a few special binary numbers.

2. Locate the binary conversion law.

3. The transfer of binary understanding of the rules.

4. For example digestion, a example you will understand.

~~----------------------------------------------------------------------------------------------------------------------------------------

Introduction: read the foregoing, you can look example.

----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------

A: memorize a few special binary numbers.

----------------------------------------------------------------------------------------------------------------------------------------

Q: Why only remember these numbers?

A: Because the IP address binary representation, the range is from 00000000.00000000.00000000.00000000 11111111.11111111.11111111.11111111, and 0 are binary and decimal 0, the binary 11111111 is 255 in decimal, so that the IP address to 0.0.0.0 255.255.255.255.

Decimal digits Binary representation
128 1000 0000
192 1100 0000
224 1110 0000
240 1111 0000
248 1111 1000
252 1111 1100
254 1111 1110
255 1111 1111

----------------------------------------------------------------------------------------------------------------------------------------

2. Locate the binary conversion law.

----------------------------------------------------------------------------------------------------------------------------------------

Decimal digits law
128 128+ 2^6 (64)=192
192 192+ 2^5 (32)=224
224 224+ 2^4 (16)=240
240 240+ 2^3 (8)=248
248 248+ 2^2 (4)=252
252 252+ 2^1 (2)=254
254 254+ 2^0 (1)=255
255 255 is the last

You will find the law, from 128--225, the difference between each of the two numbers are decreasing: 64-32-16-8-4-2-1 this in mind.
----------------------------------------------------------------------------------------------------------------------------------------

3. The transfer of binary understanding of the rules.

----------------------------------------------------------------------------------------------------------------------------------------
After all the above in mind, we can begin to understand the algorithm.

Rule 1:

We binary 8 bits, from right to left, power corresponding to a digital 0 (2 ^ 0) to the 7th power (2 ^ 7) 2 2. So it is written:

1111 1111
128 -64-32-16 8-4-2-1

This is not difficult to understand, remember this on ok.

Rule 2:

The X (0 <X <256) binary transfer, we start to (128.64.32.16.8.4.2.1) which together equal X. We only count add up to X, we not subtraction equal to X, as forward subtraction need to borrow a personal feeling is more complicated, it is not recommended.

Rule 3:

In the binary conversion, 128.64.32.16.8.4.2.1, the number eight, which is used, which corresponds to the position to write 1, and 0 otherwise.
----------------------------------------------------------------------------------------------------------------------------------------

4. For example digestion, a example you will understand.

----------------------------------------------------------------------------------------------------------------------------------------

Rule 1 first written down, and then began to look at an example.

Example 1:

129 converts the binary.

Algorithm: Digital in 128.64.32.16.8.4.2.1 add up to 129. We found 128 + 1 = 129.
We know that 128 in binary is 1000 0000 (initially let the numbers of your memory), plus rule number three, which number is used, which would write the number 1, so we get the answer is: 1000 0001

Example 2:

Convert 168 to binary.

Algorithm: We found that 128 + 40 + 8 = 40 = 168,32, it is 128 + 32 + 8 = 168, we write the corresponding number 1, we get the answer is: 10101000

Example 3:

Convert 244 to binary.

Algorithms: We found that we already know of the binary 240: 11110000, (before memory), then it is 240 + 4 = 244 240 binary so we will write, and then write the corresponding position 4 1. So we get the answer is 11,110,100.

Example 4:

253 is converted to binary.

Algorithms: We already know the binary 252: 1111 1100 (before memory), then that is 252 + 1 = 253, so we will write the corresponding position 1 1, get answers 11,111,101

Example 5:

80 converted into binary.

Algorithms: 64 + 16 = 80, 64 and 16 will be two written one, then get the answer: 01,010,000 foremost 0 can be omitted, so our answer can also be written as 1.01 million

Summary: We found that we converted into binary X, we are closest to the selection of the number of X, and we already had a digital memory, and then the addition. So, just remember three rules and special digital front, a little practice, you can completely mental arithmetic binary.

Guess you like

Origin blog.51cto.com/14558454/2441938