# DeepakBhalla

By Deepak Bhalla Sun 30 July 2017 1 min read

It's actually relatively easy to convert from binary to decimal in your head. Memorising a small but manageable lookup table allows you to spot patterns in binary numbers.

``````000     0
001     1
010     2
011     3
100     4
101     5
110     6
111     7
``````

From there all you need to realise is that shifting the lookup table value to the left once multiplies the value by two:

``````00001110 = (7 * (2^1)) = 14
``````

Using the lookup table we can see the pattern `111` (which in the lookup table corresponds to 7) which is shifted up by one place `(2 ^ 1)` which gives the decimal value of 14.

Processing more complicated numbers is easy:

``````00011000 = 3 * (2^3) = 24
``````

Using the lookup table we can identify the pattern `011` (which in the lookup table corresponds to 3) which we shift up 3 positions `(2 ^ 3)` which gives us the total value 24. This can also be done by identifying `110` (corresponds to 6) shifted up `(2 ^ 2)` which is also 24.

We also don't have to shift:

``````01010111 = (5 * (2^4)) + 7 = 87
``````

Here we find two patterns `101` and `111`. We shift `101` (5) up by 4 positions and keep `111` (7) where it is. The addition of the two gives the total decimal value.

``````01111001 = ((7 * (2^4)) + (4 * (2^1)) + 1) = 121
``````
Deepak Bhalla