How do you get binary to decimal faster?

How to convert binary to decimal

Binary into decimal calculation method: 1, unsigned integers, from right to left in order with the number of binary digits multiplied by the sum of the nth power of 2 (n is greater than or equal to 0); 2, signed binary integers, excluding the highest bit of the sign bit (1 is a negative, 0 is a positive), the rest of the method of unsigned binary to decimal conversion The same; 3, decimal binary into decimal numbers, 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 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 binary number of the highest digit is what number, if it is 1, 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.

Easy way to convert binary to decimal?

Method 1: from right to left with each number of binary to multiply by the appropriate power of 2, after the decimal point is from left to right

Example: binary number 1101.01 converted to decimal

1101.01 (2)

=1*2 [0] +0*2 [1] +1*2 [2] +1*2 [3] +0*2 [-1] +1*2 [-2]

=1+0+4+8+0+0+0.25=13.25 (10)

Method 2: The binary number is first written as a weighted coefficient expansion, and then summed according to the rules of decimal addition. This is called the “weighted sum” method.

For a binary number with n integers and m decimals, the weighted coefficient expansion can be written as follows: N(2) = an-1×2n-1+an-2×2n-2+? +a1×21+a0×20+a-1×2-1+a-2×2-2+? +a-m×2-m (10) where aj denotes the coefficient in the jth place, which is one of 0 and 1.

Example: binary number 1101 converted to decimal

1101 (2)

=1*2 [3]+1*2 [2]+0*2 [1]+1*2 [0]

=13 (10)

Note:

1, [] the number in parentheses represents the sub-square, such as [2] for the quadratic, [-1] is negative primary.

2. The numbers in the () brackets represent the decimal numbers, (2) is binary, (10) is decimal.

Expanded information:

The following are the binary to is decimal codes: