Binary to decimal conversion

Data representation

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:


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

Bits in the sequence 1 0 1 1 1 0 1
Position 6543210
2^{position} 6432168421
Multiply the 1st by the 3rd row 640168401
Add all the values in the 4th row64+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.