Tuesday, September 1, 2015

How to Quickly Convert Binary To Decimal In Your Head - And Then Go Faster


How to Quickly Convert Binary To Decimal In Your Head:


See this article for the original idea that inspired this post.  This post discusses an extension to that idea to make it even faster

If you go to that article at http://www.zenoli.net/2007/03/quickly-convert-binary-to-decimal-in-your-head/ then you'll see that it's a neat trick to let you just simply read from left to right while figuring out the decimal number, and with minimal memorization along the way.  

All you need to know is how to multiply by 2, add 1 or 0, and remember only one number at a time as you read from left to right going along the binary number.  No need to keep track of absolute positions, especially for longer binary numbers.

It makes use of the idea that binary digits are multiples of 2 of their respective lower positions to their right.

To summarize that article, there are two rules:

1) Multiply by 2 in binary --> shift all 1's and 0's to the left (and keep the same pattern).
2) Divide by 2 in binary --> shift all 1's and 0's to the right (and keep the same pattern).

(Although in practice I only need to remember the first rule.)




And Then Go Faster:



A powerful addition of this idea is that you can then make use of "convenient numbers" to quickly deduce other numbers and reduce both memorization and calculation time.

Here are some "convenient numbers":  5, 10, 20.

Let's use 5-digits in binary to show some examples:

Binary to Decimal:
00101 = 5
01010 = 10 = 5 x 2
10100 = 20 = 5 x 2 x 2 or = 10 x 2

Did you notice how the same three digits just shifted left when you multiply by 2?
If you just memorize that 5 = 101 in binary, then you can easily remember that ten = 1010 because ten = 5 x 2, and 1010 = "101 times two".

So for the price of memorizing two things (i.e. that 5 = 101 and this rule of shift left = x2), you get to know at least two other numbers instantly:  10 and 20.

Okay, not so impressive.

But what I said earlier is you can quickly deduce other numbers from these "convenient numbers".

What's 10101 equal to in decimal?

Well, let's see:
10100 = 20, so
10101 = 20 + 1
So then
10101 = 21.  Kaboom.

So when you see the pattern "101" in a binary number, you can intuitively figure out the number almost instantly just by "looking".  You can at least figure out the significant digits rapidly.

Now, consider that you can remember that 2 = 10 in binary, or that 1 x 2 = 2, or that the 2nd digit from the right is 2.  Any of these ways works.  Whatever is faster for you. 

How about we try converting 10110?

Remember that
10100 = 20
so
10110 = 22 because 10100 + 10 = 10110.
(10 = 2) 

Done.

Here are some more examples:

01110 = 
01010 +
00100 =
10 + 4 = 14

01111 =
01010 + 
00101 = 
10 + 5 = 15

A visual way to instantly see this is to imagine the 1's "falling" into their respective positions.

01010 = 10
00101 = 5
01111 = 15

You can probably figure out other numbers, but let's just say it pays to memorize a little to get a lot more speed, just by "looking" at the numbers instead of trying to remember mulitple numbers to add together at the same time.

Some "convenient numbers" to remember are the place values and easy patterns to see that coincide with the decimal system's base of ten, i.e.:

2,4,8,16 (binary place values)
5,10 (simple multiples of base 10)

("1" pattern)
00001 = 1
00010 = 2
00100 = 4      = 2 x 2
01000 = 8      = 4 x 2
10000 = 16    = 8 x 2

("101" pattern)
00101 = 5
01010 = 10    = 5 x 2

Another interesting pattern to think about:

("11" pattern)
00011 = 3
00110 = 6      = 3 x 2
01100 = 12    = 6 x 2

_________________________

LINKS TO OTHER STUFF: 

Favourites
Programming
Original Art
Games

Chinese Learning Projects:
 - Book
 - HSK 1
 - HSK 5
 - Homonyms Mnemonics