# Binary to decimal conversion

What you should know:

In the previous lesson we saw that every bit in a binary number has a value that can be calculated using the following rules:

 Bit Value 0 The value is always 0 1 2^{position}, where position starts from 0 at the rightmost part of the sequence and increases moving to the left.

To convert a binary number to decimal, all we have to do is calculate the value of every bit in the sequence ad add them all to get the final result.

For instance if we wanto to convert the binary number:

1011101

We can perform the calculation as shown in the following table:

 Bits in the sequence 1 0 1 1 1 0 1 Position 6 5 4 3 2 1 0 2^{position} 64 32 16 8 4 2 1 Multiply the 1st by the 3rd row 64 0 16 8 4 0 1 Add all the values in the 4th row 64+0+16+8+4+0+1=93

The final result is 93.

The second and third row are always the same and are just used as a reference to calculate the values in the fourth row.