/* iSubnet: 01.d. Number Systems: Hexadecimal */ <iSubnet>

20061208

01.d. Number Systems: Hexadecimal

We're going to be working with binary a lot more, a whole lot more. But for the sake of comparison, now is a good time to look a another "differently-based number system" that will crop up in networking, base 16. Base 16 is also called "hexadecimal", which means something like "six plus ten". It's called "hex" for short, but it can feel like something of a curse, too.

We're getting familiar with the types of things that we look for in a number system. Since it is called base 16, we can infer that there is a range of 16 values for a given digit. Obviously, our decimal range of 0 thru 9 is insufficient. Hex digits follow the sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Pretty tricky, huh? (The letters are usually in caps, by the way.) To build a value table, we start with the rightmost, least significant position. That is worth 16 to the zero-eth power, which is 1. (Because anything to the power of zero is one.) In the next-most significant position is the 16's place, because 16 to the power of 1 is 16. You can see that it gets mathier in a hurry. The third digit from the rightmost has the value multiplier of 162. That's 16 times 16 or 256. The fourth position is 163, 16 times 16 times 16. (It's also 256 times 16, of course.) That's 4096!

If we want to translate a number like FEED (which is a very cool number), it's going to get very big. There's a bit of notation that you sometimes see that indicates that the number is hex and that is a zero and an x. You call it hex, if it's pronounced at all. So 0xD times 1 = 13, if you can wrap your brain around that. Then in the 16's place, E (which is 14) times 16 = 224. But E times 256 = 3584. And an F in the 4th digit is F (or 15) times 4096 = 61,440. So FEED = 13 + 224 + 3584 + 61,440; which equals 65,261. If you need to pause this and put your head down between your knees for a few deep breaths, go ahead.

Why do you suppose that base 16 is going to be useful if computers only have 2 fingers, if their native number system is binary? Let's harken back to that binary value table that we built. Do we remember the greatest value that we said we could get in our 4 bit nibble? It was 15; the range of values for 4 bits is 0 thru 15. 16 different values. Aha! That's pretty sneaky - we can put 4 binary digits, a whole nibble, into 1 hex digit. Yes, computers may only have 2 fingers, but they can count on them really, really quickly. If we think that 65,261 was an unwieldy representation, what will 0xFEED look like in binary? for starters, how many binary digits do we expect? If it's 4 hex digits and each hex digit represents 4 bits, it's going to be a 16 digit binary number, right? While this is just the kind of translation fun that we're going to get deep into shortly, for now you'll just have to trust me that 0xFEED = 1111111011101101.

Actually, you don't have to trust me. If you're using iTunes, bring up your computer's calculator. Set it to programmer or scientific mode, whatever it is on your OS. You can translate from decimal to binary to hex to your heart's content. It's a great way to check your work as you practice translating by hand. Make no mistake about it, you have got to be able to do all of these calculations by hand and you absolutely must thoroughly understand the principles. The same principles that apply to subnetting apply to more "advanced" concepts like supernetting. Once you really get it well enough that the subnetting questions on your CCNA test are gimmees and you're working in the field, then you can use a subnet calculator. But you really can't rely on them if you don't completely understand the principles of the math. Until then, use them only to check your calculations.

Okay, where were we? We were comparing these number systems and their application to working with our 2-fingered computers. You've probably seen some hex data if you've done any html or other basic computer color manipulation. The standard is that a color is specified by red, green, and blue levels of 0-255 represented in hex. For instance, you can get a nice sea green with 0x009966, complimented by lovely shade of cantaloupe, or 0xFF9933. Notice that they both have the same highish levels of green (the 99 byte) and a slight variance in the blue. It's the complete presence or absence of red that changes the color. What a difference a byte makes.

Of course, one bit can be the difference between a match or no match, but the byte is the primary grouping of bits that we use. In the calculators I just mentioned, you might notice mention of the octal number system. Because base 8 represents the byte (8 bits of data), it has been used in other computer related functions. We won't need octal, but the byte will come up all the time. You'll see hardware addresses of network adapters represented by 6 hex bytes. The address 00:16:cb:bc:5a:37 is much easier to read than it's 48-bit binary equivalent. By the way, you will also see the MAC address notation in these other formats (00-16-cb-bc-5a-37 and 0016.cbbc.5a37).

Next==>

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?