Monday, November 9, 2009

converting binary to decimal in mind

converting binary to decimal in mind.

You only need to remember first 8 numbers:
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7

Then, you need to know that shifting to left by one digit multiplies the number by 2.

take 3 digits from left-most digits each time:
1010b = 101b x 2^1 = 5 x 2 = 10d
10100b = 101b x 2^2 = 5 x 4 = 20d

So, when you see something like 101011, you can process it this way:
-> 101000b + 11b
-> 5 * 2^3 + 3 = 43d

So, when you see something like 10101110, you can process it this way:
-> 10100000b + 01100b + 10b
-> 5 * 2^5 + 3 * 2 ^2 + 2 = 174d

and so on.

It’s easier than it looks at first glance.

No comments: