decimal to binary
I’ve been reading a book on the CCNA certification. Part of the exam has to do with being able to manually convert numbers between binary, decimal and hex. I’ve struggled with that concept of being able to do it on paper an easy way but in this particular book, the author spelled out a very simple way to do this that just clicked and will now stick with me for life. Binary numbers are counted in powers of 2 relative to decimal numbers. That is the most confusing thing that I want to say about the subject. It should get easier from here on.
Typically binary numbers are represented in 8-bits or 1-byte. This just means there are 8 digits. These 8-bits can represent any decimal number between 0 and 255. That’s it, any higher numbers and you have to add more bits to represent it. Now for the fun part. Draw a chart on a piece of paper like this:
If you look at the chart, you’ll notice a relation to the numbers. Starting with 2, each number is double the number to the right of it. If you can remember this chart, you are over half way there. So now pretend you have a decimal number like 190 that you need to convert to binary. To convert it, you need to find the numbers in the chart, starting from the left, that will add up to 190. For starters, we know that 128 will fit in to 190 so let’s mark that one off with a one.
The next number, 64 won’t fit. That would add up to 192 so we’ll mark that one with a zero.
Think of it like playing blackjack. You want to get to 21 but you never want to go over. So keep adding numbers left to right until you reach the correct number, if you go over, skip that number. Adding 32 brings us to 160, add 16 and that gives us 176. We’re still not over so keep going.
Adding 8 brings us to 184, 4 more gives us 188. 2 more gives us 190 and we’re done so zero out the last bit.
So there you have it. 190 in decimal works out to 10111110 in binary. With a little practice, you can easily do these in your head. As you can see from the chart, it’s even easier to go backwards. Just add up the numbers that are set to one and skip the ones that are set to zero. Now for the bonus round!
binary to hexadecimal
Hex is something that a lot of people find confusing. I still find it confusing to convert decimal to hex and vice versa but I have found that it’s VERY easy to convert from binary to hex and back. Let’s take the same number we were just working with. 190 or 10111110. To do hex, we have to split the one byte into two nibbles. This is easier than it sounds. We just split the chart into two halves but write the binary number straight across as if nothing has changed. This is because each hex number can only represent “0″ through “15″ or more accurately “0″ through “F”. The chart looks like this now:
So now all you do is add up each nibble separately. The first one on the left gives us 11 or “B”. The second nibble adds up to 14 or “E”. So 190 in decimal equals 10111110 in binary which equals “BE” in hexadecimal. Personally I find it easier to convert decimal to binary before trying to convert it to hex but your mind may work differently.
If you like the content on this site, please support it by using this link to order from Amazon. You know you were going to go there and buy stuff anyhow so why not help me pay the hosting bill.