Quickly calculate the way to convert decimal to binary

       All data in the computer is represented by 0 and 1. Our conventional way of calculating binary is to divide a number by 2 if it can be divided by 2, it will be 0. If it is not divided, then take 1 and then divide, and finally take out 0 and 1 sorted forward is the final binary number. This method is very time-consuming, laborious and error-prone. In fact, the binary number can be calculated quickly by finding the law.

1. First of all, we need to know that the binary number of the number of the power of 2 is n 0 after 1, as follows:

2 to the nth power Decimal Binary
1 2 10
2 4 100
3 8 1000
4 16 10000
5 32 100000
6 64 1000000
7 128 10000000
8 256 100000000
........ ...... ......

 

2. It is necessary to split a certain number into multiple sums of powers of 2, as follows:

145=128+16+1, because 128=2^7, 16=2^4, 1=2^0, so binary can be expressed as:

10000000+10000+1=10010001, so the binary number of 145 is 10010001. Is it very simple, hahahaha...

Guess you like

Origin blog.csdn.net/u013804636/article/details/107814411