Calculation formula for binary to decimal conversion?
Binary to decimal conversion is calculated as follows: 1, unsigned integers, from right to left, multiply the number in the binary digit by the sum of n powers of 2 (n is greater than or equal to 0); 2, signed binary integers, remove the sign bit in the highest bit (1 is negative, 0 is positive), the rest of the unsigned binary to decimal conversion method is the same; 3, the conversion of decimal binary to decimal number, from the decimal point on the first bit of the binary digits multiplied by 2 negative primary plus the second bit of the binary digits multiplied by 2 negative quadratic, and so on the nth bit of the binary digits multiplied by 2 negative n times.
1, the unsigned integer binary number into decimal method
Unsigned integer binary into decimal number, from the first bit of the right side of the binary number, from right to left, the first binary position multiplied by the number of the corresponding digit of the power of 2, and then add the product of each can be obtained by the binary number of the corresponding decimal number.
[Example] Convert the binary number 1101001 to a decimal number.
Analysis: Starting from the first digit on the right side of the binary number 1101001, the first digit is 1, so there is 1=1, the second digit is 0, so there is 0=0, the third digit is 0, so there is 0=0, the fourth digit is 1, so there is 1=8, the fifth digit is 0, so there is 0=0, the sixth digit is 1, so there is 1=32, and the sixth digit is 1, so there is 1=1.
And then all the products can be added to get 1+0+0+8+0+32+64=105, so the binary number 1101001 is converted to decimal number is 105.
2, with the sign of the binary integer into a decimal number of methods
With a sign of the binary number into a decimal number, the first observation of the highest bit of the binary number, what is the number, and if it is 1, then it means that it is negative. If it is 1, it means it is a negative number, if it is 0, it means it is a positive number, determine the sign and then come to convert to decimal number.
[Example] Convert the signed binary number 1000000000010000 to decimal.
Analysis: signed binary number of the original code, the highest bit represents the conforming bit, we first observe that the highest bit is 1, it means that this is a negative number, so we can find this binary number corresponding to the decimal number is – (0 + 0 + 0 + 0 + 0 + 1) = -16.
3, decimal number into decimal number of methods
Decimal number of binary number into a decimal number of method, from left to right, with the number of binary digits multiplied by the negative digit power of 2, and then add all the products can be obtained.
[Example] Convert binary 1.1101 to decimal.
Analysis: The integer part is converted to a decimal number as 1=1,
The fractional part 1+1+0+1=0.8125,
then the decimal number corresponding to the binary number 1.1101 is 1.8125.
Binary to decimal formula
Method: “Expand and sum by weight”.
Binary 1011 converted to decimal is 11: