How to calculate the binary to decimal code

How to convert binary to decimal

First of all, let’s take an example: decimal 123 = 1 * 100 + 2 * 10 + 3 * 1, where 100 is 10 squared, 10 is 10 to the first power, 1 is 10 to the zero power, respectively, in the hundredths, tenths, and digits, which is also called the bit weights of the corresponding positions, then binary is also the same reason.

Binary to decimal conversion is: the binary number in each position multiplied by the bit weights in the position, and then add. Such as 101101 converted to decimal is 1 * 2 of the 5th + 0 * 2 of the 4th + 1 * 2 of the 3rd + 1 * 2 of the 2nd + 0 * 2 of the 1st + 1 * 2 of the 0th = 32 + 8 + 4 + 1 = 45; this 45 is the corresponding decimal number.

Binary to decimal, how to calculate ???????????

Binary to decimal conversion: the base is multiplied by the power, and then added together, simplifying the operation can be left out of the term where the number of digits is 0, (because 0 multiplied by any other number that is not 0 is 0). The decimal part is the same, but with less precision.

Method: “Expanding the sum by power”

Example: 10001111

1×2⁷+1×2³+1×2²+1×2¹+1×2⁰=143, so the decimal representation of 10001111 is 143.

The rule: the number of digits in the single digit is 0, the number of digits in the tens digit is 1, …… , in increasing order, while the number of times the number in the tenths place is -1 and the number of times the number in the hundredths place is -2, …… , in decreasing order.

Binary to decimal how to calculate

Binary to decimal algorithm is as follows:

Method one

Decimal point before or integer to be from right to left with each number of binary to multiply by the corresponding sub-power of 2 and incremental, decimal point is from left to right multiplied by the corresponding negative sub-power of two and decremental.

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 “weighted addition.


Binary is a widely used number system in computing technology. Binary data is a number represented by two digits, 0 and 1. It has a base of 2, a rounding rule of “two into one” and a borrowing rule of “borrowing one as two,” and was discovered by the 18th-century German mathematical philosopher Leibniz. Current computer systems use what is essentially a binary system.

Data is stored in computers mainly in the form of complements. The binary in a computer is a very tiny switch, with ‘on’ for 1 and ‘off’ for 0.

The invention and application of computers in the 20th century, which has been called one of the major landmarks of the Third Scientific and Technological Revolution, has been a major success, as digital computers can only recognize and process symbols consisting of ‘0’ . ‘1’ symbol strings consisting of codes. Its mode of operation is precisely binary. 19th century Irish logician George Boole’s process of thinking about logical propositions was transformed into a process of thinking about the symbols “0”.””. 1” in a sort of algebraic calculus, binary being a system of rounding off every two digits.

Main features:


The digital device is simple and reliable, using few components; there are only two digits, 0 and 1, so that each of its digits can be represented by any component with two different stable states; the basic rules of arithmetic are simple, and arithmetic operations are convenient.


When a number is represented in binary, there are many bits. Therefore, in practice, the use of the digital system is mostly fed into the digital system before the use of decimal, fed into the machine and then converted to binary numbers, so that the digital system for arithmetic, the end of the operation and then converted binary to decimal for people to read.

The conversion of binary and hexadecimal to each other is more important. However, the conversion of these two does not need to be calculated, and every C, C++ programmer can do it to see a binary number and directly convert it to hexadecimal number and vice versa.

How do you do the math to convert a binary number to a decimal number?

The binary to decimal formula is:


To go from right to left multiply each digit of the binary number with the corresponding power of 2,after the decimal point it is from left to right

For example: The binary number 1101.01 is converted to decimal

1101.01 (2) = 1*20 + 0*21 + 1*22 + 1*23 + 0*2-1 + 1*2-2 = 1+0+4+8+0+0.25 = 13.25 (10)


The progressive system, also known as the counting system with rounding, is A human-defined method of counting with progressions (there are methods of counting without progressions, such as the primitive knot counting, the “positive” counting commonly used for singing tickets, and the similar tallymark counting). For any of these systems, the X system means that the numbers in each position are rounded to the nearest X. For decimal systems, the numbers are rounded to the nearest ten. In decimal, it’s one to ten, in hexadecimal it’s one to sixteen, in binary it’s one to two, and so on, and in x-advanced it’s one to x.

Progressive/positional counting is a form of notation, also known as rounding/place value counting, in which a finite number of digit symbols can be used to represent all numerical values. The number of digit symbols that can be used is called the base (en:radix) or the base, and the base is n, which can be called the n-progressive system, or n-progressive system for short. Nowadays, the most commonly used is decimal, usually using 10 Arabic numerals 0-9 for notation.