# How can I convert binary to decimal?

An easy way is to use the calculator in Windows.It has a programming option, where you can easily convert from decimal, to binary, but also hexadecimal.

If you want to do it by hand:

A binary number is made up of powers of 2, as the decimal system is made up of powers of 10. You can also write a binary number of n digits as

2 ^ n + 2 ^ (n-1) +… + 2 ^ 4 + 2 ^ 3 + 2 ^ 2 + 2 ^ 1 + 2 ^ 0.

Where you each time the figure at spot I (0 or 1) multiplied by the power

To go from binary to decimal, count all the powers together (from right to left is easiest)

For example, binary: 1010101

So

1010101 =

**1*** 2 ^ 6 + **0*** 2 ^ 5 +** 1*** 2 ^ 4 + **0*** 2 ^ 3 + **1*** 2 ^ 2 + **0*** 2 ^ 1 + **0*** 2 ^ 0 =

**1*** 64 + **0*** 32 + **1*** 16 + **0*** 8 + **1*** 4 + **0*** 2 + **1*** 1 = 85

64 + 0 + 16 + 0 + 4 + 0 + 1 = 85

And for example

11011111 =

**1*** 2 ^ 7 + **1*** 2 ^ 6 + **0*** 2 ^ 5 + **1*** 2 ^ 4 + **1*** 2 ^ 3 + **1*** 2 ^ 2 + **1*** 2 ^ 1 + **1*** 2 ^ 0 =

**1*** 128 + **1*** 64 + **0*** 32 + **1*** 16 + **1*** 8 + **1*** 4 + **1*** 2 + **1*** 1 =

128 + 64 + 0 + 16 + 8 + 4 + 2 + 1 =

223

Conversely, you have to look at the greatest power in the number, make a 1 of it and subtract the value of the number.Then with the rest do the same thing until you get to 1.

So 219 fits in there 128, but 256 doesn’t, so the biggest one is 128.

219 -128 = 91.

91 there fits 64.

91 -64 = 27, which yields a 1 for 64

In 27, 32 does not fit, so that becomes a 0, but 16 does, so 16 gets a 1

27-16 = 11, in 11 fits 8, so 8 gets a 1

11 -8 = 3, in 11 does not fit 4, so 4 gets a 0, but 2 does, so 2 gets a 1

3-2 = 1, and finally we keep a 1.

219 = 1 * 128 + 91 = 1 * 2 ^ 7 + 91

91 = 1 * 64 + 27 = 1 * 2 ^ 6 + 27

27 = 0 * 32 + 27 = 0 * 2 ^ 5 + 27

27 = 1 * 16 + 11 = 1 * 2 ^ 4 + 11

11 = 1 * 8 + 3 = 1 * 2 ^ 3 + 3

3 = 0 * 4 + 3 = 0 * 2 ^ 2 + 3

3 = 1 * 2 + 1 = 1 * 2 ^ 1 + 1

1 = 1 * 1 = 1 * 2 ^ 0

Now write the factors in succession and you will get 219 = 11011011

Pfoe This is a question with multiple answers.Namely, what for a binary number do we have it? Floating-point? Fixed-point? Integer? Is this signed/unsigned? First of all, I will answer the most obvious interpretation of the question. Namely, how do I determine the decimal value of an unsigned integer (a whole number that can only be positive).

**Integer:**

As Quora user in his reply already indicates that is quite simple, just to use his example, we will convert 1010101 to decimal.To quote: “A binary number is made up of powers of 2, as the decimal system is made up of powers of 10. You can also write a binary number of n digits as “

2 ^ n + 2 ^ (n-1) +… + 2 ^ 4 + 2 ^ 3 + 2 ^ 2 + 2 ^ 1 + 2 ^ 0

So 1010101 =

**1*** 2 ^ 6 + **0*** 2 ^ 5 +** 1*** 2 ^ 4 + **0*** 2 ^ 3 + **1*** 2 ^ 2 + **0*** 2 ^ 1 + **0*** 2 ^ 0 =

**1*** 64 + **0*** 32 + **1*** 16 + **0*** 8 + **1*** 4 + **0*** 2 + **1*** 1 = 85

**FIXED-POINT:**

Okay, now I’ve only given a shorter version of Bart his answer, but what if we meant a fixed-point number?Fixed-point representation is a way to display comma numbers. It is the easiest to explain by an example namely 101.0101. The point between 101 and 0101 is to indicate that the type of fixed-point number we are talking about is Q (3.4), 3 bit for the integer and 4 for the fraction (after the comma).

The first part (for the point) we already know how to count this out, because this is still an ‘ integer ‘.

101 = 2 ^ 2 + 2 ^ 0 = 4 + 1 = 5

The group is actually counting in the same way, namely

2 ^-1 + 2 ^-2 + 2 ^-3 +… + 2 ^-(n-1) + 2 ^-N

So 101.0101 =

**(1*** 2 ^ 2 + **0*** 2 ^ 1 +** 1*** 2 ^ 0**)** + **(0*** 2 ^-1 + **1*** 2 ^-2 + **0*** 2 ^-3 + **0*** 2 ^-4**) **=

**(1*** 4 + **0*** 2 + **1*** 1**)** + **(0*** 0.5 + **1*** 0.25 + **0*** 0125 + **1*** 0.0625**)** = 5 + 0.3125 = 5.3125

**Floating-point:**

Another representation, although we can basically display everything in Fixed-Point it is not always handy (storage wise, numbers are quickly “big” and computational wise, arithmetic is not always as efficient).This form is a lot more complex than the previous one to understand.

We take again as example 10.10101

The first 2 bit indicate the ‘ exponent ‘, the last 5 the ‘ mantissa ‘.We already know that the exponent 10 equals 2. And the mantissa is, just as with fixed-point to be calculated and equals 0.65625, however, + 1 is done here to calculate the result according to the following line:

(1 + mantissa) * 2 ^ (exponent) = (1 + 0.65625) * 2 ^ (2) = 1.65625 * 4 = 6,625

**Enne negative numbers then?**

Almost forgotten!Again, there are several representations, the most common being “two’s complement” the reason is that for integer and fixed-point arithmetic remain exactly the same as for positive numbers (so it can be done with the exact same hardware be without extra steps!)

We are once again taking our example of 1010101, this was 85 as an unsigned integer.Supposing we now want a signed integer of 85 then we will need to add a sign bit so 85 = **0**1010101.To then display-85 in two’s complement we inverting all the bits (so every 1 becomes a 0 and vice versa) and we count 1 on it.

**0**1010101 = 85**1**0101010 =-86**1**0101011 =-85

Exactly the same goes for fixed-point.For floating-point we have only two sign-bits for both the exponent and the mantissa. I.e.

**00**10.10101 = (1 + 0.65625) * 2 ^ (2) = 6,625**10**10.10101 =-(1 + 0.65625) * 2 ^ (2) =-6,625**01**10.10101 = (1 + 0.65625) * 2 ^-(2) = 0.4140625**11**10.10101 =-(1 + 0.65625) * 2 ^-(2) =-0.4140625