April 24, 2005

Base 2, 8, 10, and 16 (Also known as Binary, Octal, Decimal, and hexidecimal)

     We, as humans, are normally born with 10 fingers, and as such, we base our numbering system on groups of 10. This means that we have single digit representation of all numbers until 10. But imagine that we had 16 fingers. Then we would have a base 16 system meaning that there would be single digit representations of all digits before 16. Despite the fact that we don't have 16 fingers, a system involving 16 digits does exist. It's known as Hexidecimal.
     In hexidecimal you count as follows: 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10. So in hexidecimal 10H = 16 (Note: The H is there to clarify that it is 10 in Hexidecimal). Confused? You should be, but despite the fact that it is confusing computers operate on a combination on hexidecimal and binary, so to stick with the rest of what I'm going to say, you'll have to muddle along this explaination. So, back to hexidecimal!
     So now that you know that 10H = 16, you can assume that anything in the second colum is multiplied by 16. So 20H = 32. Do you understand? Good. Now onto the more confusing part. It now stands to reason that instead of a "tens place", we have a "sixteens place". Well then what about the "hundreds place"? Since 100 is actually just 10 squared, the same rule applies for Hex. It is the "two-hundred-fifty-sixths place". So 100H = 256.
     So now that you have a general understanding of hex let's try a slightly harder conversion: What is 3C9H in regular base-10 decimal? Don't panic, I'll walk you through it:
     1) Here's a little chart to help you out with the hardest part:

256s place16 place1s place

So we start by multiplying the 3 by 256 because it is in the "256s place" Which gives us 768, write it down, you'll need to remember it.
      2) Next we multiply C by 16. Now if you remember, C is 12 (...9, A, B, C...), so we multiply 16 by 12, because C is in the "16s place". That gives 192, write that down.
      3) The last column is the easiest: the ones column. Simply multiply the value in the last column by 1: 1 times 9.
      4) Add them all together and we get our value: 768+192+9 = 969. Good Job! You just converted your First number from hex to decimal. Here's a chart that is easier to follow for how the places work:
16^3s place16^2s place16^1s place16^0s place

Do you see the pattern? Good.

Want a harder problem? Try converting 6B2B3F9H.

     I'm not going to bother telling you how to convert in the other direction because that would take to long. Anyway, I'm learning assembly, and so I'm learning Hex and binary through and through. Sorry about the lack of updates, hope to get back on track this week.

Posted by Kickmyassman at April 24, 2005 09:51 PM

If you've ever heard Tom Lehrer's song, "New Math," you'll remember this sort of thing you're trying to teach your readers. At one point, he says, "Well, actually the book wanted you to do it in base eight. But don't worry--base eight is just like base ten...if you're missing two fingers!" He then goes on teaching through song.

Posted by: Eric at April 25, 2005 03:33 PM
Post a comment

Remember personal info?