Fast transfer binary and hexadecimal

How fast are binary, decimal, hexadecimal conversion
to binary remember the 8421
First we look at a binary number: 1111, how much is it?
You may also be calculated as: 1 × 2º + 1 × 2¹ + 1 × 2² + 1 × 2³ = 1 × 1 + 1 × 2 + 1 × 4 + 1 × 8 = 15.

We must remember that every direct weights 1111, and from high to low in mind: 8, 4. That is, the highest weight value 2³ = 8, then followed by 2² = 4,2¹ = 2,2º = 1.

Remember 8421, for any a 4-bit binary number, we can quickly calculate the decimal value of its corresponding.

Next, we practice for rapid calculation by means 8421, the binary conversion 2,10,16
1111 =. 8. 4 + 2 + 15 = F. +. 1 =
1110 =. 8. 4 + 14 + 2 + 0 = E =
1101 = . 8 +. 4 + 0 +. 1 = 13 is = D
1100 is =. 8 +. 4 + 0 + 0 = 12 is = C
1011 =. 8 + 0 + 2 +. 1 =. 11 = B
1010 =. 8 + 0 + 2 + 0 = 10 = A
1001 + 0 + 0 = 8 = 9 = 1 + 9
......
0001 + 0 + 0 = 0 + 1 = 1 1 =
0000 = 0 + 0 + 0 = 0 + 0 = 0

Binary number to be converted to hexadecimal
binary number to be converted to hexadecimal, that is, to a period of four were converted to hexadecimal.
The (number two system behavior, the following corresponding hexadecimal):
1111 1101, 1010 0101, 1001 1011
the FD,. 5 A, B. 9

Hexadecimal number is converted to a binary number
, in turn, when we see FD, how quickly this hexadecimal number is converted to binary it?
First converted F:
see F, we need to know that it is 15 (you may not be familiar with the five A ~ F number), then 15 How to take care of it 8421? It should be 8 + 4 + 2 + 1, the four are all 1: 1111.
D conversion and then
see D, know that it is 13, 13, 8421 How to take care of it? It should be: 4 + 8 + 1, namely: 1101.
Therefore, FD is converted into a binary number is: 11111101

Decimal number is converted to binary
Due to convert hex into binary fairly straightforward, so we need to convert a decimal number into a binary number can also be converted first into hexadecimal, and then converted to binary .
For example, the decimal number system 1234 is converted into the number two, if you have divided by 2, directly binary number needs to be calculated more frequently. Therefore, we can divide by 16 to give the hexadecimal:
dividend calculation process commercially remainder
1234 1234/16 77 2
77 77/16 13 is. 4 (D)
. 4. 4 0 4/16
result hexadecimal: 4D2
Then we 4D2 write directly to binary form:
0100
1101
0010
wherein enantiomeric relationship:
0100 -. 4
1101 - D
0010 - 2

Converts a binary number to decimal
Similarly, if a binary number is very long, we need to convert it to 10 decimal number, in addition to methods previously learned it is that we can first convert the binary to hexadecimal, then converted to decimal.
The following are examples of a binary type int:

0,110,110,111,100,101 1,010,111,100,011,011
us a set of transformation by four hexadecimal: 6D E5 AF 1B
decimal convert hexadecimal
Mining remainder theorem decomposition, for example hexadecimal 487,710 revolutions:

÷ 16 = 30481 ... 487710 .14 (E)
30481 ÷ 1905 = 16 .1 ...
1905 ÷ 119 = 16 .1 ...
119 ÷ 16 = ... .7. 7
. 7 ÷ 16 = 0 ... .7
This meter to 487 710 (10 ) = 7711E
(16) ----------------
Disclaimer: This article is CSDN blogger "North_Spark 'original article, follow the CC 4.0 BY-SA copyright agreements, please attach a reprint the original source link and this statement.
Original link: https: //blog.csdn.net/diyu122222/article/details/80692904

Guess you like

Origin www.cnblogs.com/cfas/p/11601117.html