| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Decimal, Binary, Octal and Hexadecimal Numbers (Page 3 of 3) Hexadecimal Numbers Octal numbers were at one time quite commonly used, but are much less popular today. The problem with octal is that it divides bits into groups of three, but sets of binary numbers typically use a number of bits that is a multiple of four. An alternative method was defined that does the same thing but using groups of four. Since there are four bits in each group, each can have one of sixteen values, and this is called the hexadecimal or base 16 numbering system. It is also commonly called just hex for short.
Now, let's go back to the example just above, 11110100 in binary, 244 in decimal. We divide this into groups of four, to get (1111)(0100). The binary value 1111 is 15, and 0100 is four, so we have (15)(4). Hmm, now we have a bit of a problem, don't we? We need to be able to represent 15, but we only have 10 numerals. To get around this, in hexadecimal numbers the values 10, 11, 12, 13, 14, or 15 are represented by the letters A, B, C, D, E and F respectively. So, 11110100 in binary is (15)(4), or F4 in hexadecimal (also shown in Figure 9). Hexadecimal numbers are in some ways even less intuitive than binary ones. After all, it takes some practice to get used to thinking of letters as numbers. However, they are very useful due to the way they compactly represent binary information. Where 1,000,000 in decimal is 11110100001001000000 in binary, it is only F4240 in hexadecimaleven shorter than the decimal number, since 16 is larger than 10. Also, a single byte has eight bits, so it can be represented using only two hexadecimal digits. Due to this convenience factor, hex numbers are widely used in the field of computing, including networking. For example, you will often see values expressed in hexadecimal for items such as MAC addresses, and for representing different types of information in frame or packet formats.
If you see a number that has a letter from A to F in it, you know it is a hex number, but not all hex numbers have those digits. Hex numbers are usually displayed in a special notation, to avoid confusing them with decimal numbers. That notation is either a prefix of 0x or a suffix of h (sometimes both). Thus, the number 54 is just 54, but 0x54 is 54 in hexadecimal, which is 5 times 16 plus 4, or 84 in decimal. Be sure to watch for these representations.
Home - Table Of Contents - Contact Us The TCP/IP Guide (http://www.TCPIPGuide.com) Version 3.0 - Version Date: September 20, 2005 © Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved. Not responsible for any loss resulting from the use of this site. |