- 2020-08-15 12:53
*views 2*- assembly

I don't know why I always forget the method of base conversion after a period of time

I don't know why

Take a look at this knowledge recently , And think about the principle

Binary to decimal

example ：

Binary number 1001B=1*2^0 + 0*2^1 + 0*2^2 + 1*2^3=1 + 8 =9

principle ：

A decimal number 632 It can be expressed as

=600 + 30 + 2

=6*10^2 + 3*10^1 + 2*10^0

=632

Similarly, a binary number 11011 It can be expressed as

10000+ 1000+ 000 + 10 +1

=1*2^4+ 1*2^3+ 0*2^2 + 1*2^1 +1*2^0

=16 + 8 + 0 + 2 +1

=27

Decimal to binary

A=a(2^0)+b(2^1)+c(2^2)+d(2^3)+e(2^4) （ Isn't the following sum the decimal process ）

Now assume that the number is not binary , Divide by base 2 have to

A/2=a(2^0)/2+b(2^1)/2+c(2^2)/2+d(2^3)/2+e(2^4)/2

At this time, due to a(2^0)/2 This formula can't be divisible , And the other terms can certainly be divisible . therefore a(2^0) It has to be left over , that is a It has to be left over

（ because a and a(2^0) Always equal ）, So you can start with the remainder a See the first bit

Business gain ：

b(2^0)+c(2^1)+d(2^2)+e(2^3), Divide by the base number 2 The rest b, and so on .

When this number can no longer be 2 Division time , The rest a The number of digits is lower than the original number , And then the remainder is high , So write all the remainder in reverse . nothing less than edcba

Technology

Daily Recommendation

views 26

views 2

©2019-2020 Toolsou All rights reserved,

Image format conversion Count the number of letters （java Language implementation ） Using orthogonal table method to design test cases One is called “ Asking for the train ” A small village Finally got the train VaR - Value at risk - Monte Carlo method - Python How to build data security system ?python: Convert a file to a binary file (binary)vue use vue-clipboard2 Realize the function of copy link 13. solve git Merge conflict uniapp Summary of page value transfer