https://jingyan.baidu.com/article/425e69e6e93ca9be15fc1626.html
Article Directory
How to convert decimals between binary decimals
Convert decimal fractions to binary:
The decimal part is multiplied by 2, and the integer part is taken from left to right and placed after the decimal point, until the decimal point is 0.
eg 1: Infinite loop is never 0 after the decimal point
Decimal | Binary | ||
---|---|---|---|
0.1 | 0. | ||
Decimal place*2 | 0.2 | 0 | Integer bit is 0 |
0.4 | 0 | ||
0.8 | 0 | ||
Decimal place*2 | 1.6 | 1 | Integer bit is 1 |
Decimal place*2 | 1.2 | 1 | |
0.4 | 0 | ||
0.8 | 0 | ||
1.6 | 1 | ||
1.2 | 1 | ||
0.4 | 0 | ||
… | … | ||
0.1 = | 0.0001100110 |
eg 2: 0 after the decimal point
Decimal | Binary | ||
---|---|---|---|
0.125 | 0. | ||
0.25 | 0 | ||
0.5 | 0 | ||
1.0 | 1 | After the decimal point is 0, the calculation is terminated | |
0.125 = | 0.001 |
Perform binary to decimal conversion.
The conversion of binary decimals to decimals is mainly to multiply by the negative power of 2. Starting from the decimal point, multiply by the negative power of 2, the negative power of 2, and the negative power of 2.
eg:
Binary | Decimal | ||
---|---|---|---|
0.001 | 0. | ||
First place*1/2 | 0*1/2 | 0 | + |
Second place*1/4 | 0*1/4 | 0 | + |
Third place*1/8 | 1*1/8 | 125 | |
0.001 = | 0.125 |
Online base conversion
支持在2~36进制之间进行任意转换,支持浮点型
https://tool.oschina.net/hexconvert/
You can try it yourself and compare the results with tools
If you want to try positive and negative conversion, you can read the following article
Hexadecimal to decimal binary conversion process (same positive and negative) (1)