Please Whitelist This Site?

I know everyone hates ads. But please understand that I am providing premium content for free that takes hundreds of hours of time to research and write. I don't want to go to a pay-only model like some sites, but when more and more people block ads, I end up working for free. And I have a family to support, just like you. :)

If you like The TCP/IP Guide, please consider the download version. It's priced very economically and you can read all of it in a convenient format without ads.

If you want to use this site for free, I'd be grateful if you could add the site to the whitelist for Adblock. To do so, just open the Adblock menu and select "Disable on tcpipguide.com". Or go to the Tools menu and select "Adblock Plus Preferences...". Then click "Add Filter..." at the bottom, and add this string: "@@||tcpipguide.com^$document". Then just click OK.

Thanks for your understanding!

Sincerely, Charles Kozierok
Author and Publisher, The TCP/IP Guide


NOTE: Using software to mass-download the site degrades the server and is prohibited.
If you want to read The TCP/IP Guide offline, please consider licensing it. Thank you.

The Book is Here... and Now On Sale!

Read offline with no ads or diagram watermarks!
The TCP/IP Guide

Custom Search







Table Of Contents  The TCP/IP Guide
 9  Networking Fundamentals
      9  Backgrounder: Data Representation and the Mathematics of Computing

Previous Topic/Section
Binary Information and Representation: Bits, Bytes, Nibbles, Octets and Characters
Previous Page
Pages in Current Topic/Section
12
3
Next Page
Decimal, Binary, Octal and Hexadecimal Number Conversion
Next Topic/Section

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.

Note: As an interesting “sidebar”, the term hexadecimal was not the first one used for base-16 numbers in computing. Originally, these were called sexadecimal numbers. This is actually the correct term, since Latin prefixes (sexa-) are normally used for numbers, not Greek ones (hexa-). However, in the early 1950s, IBM decided that the word “sexadecimal” was just a little too “provocative” for their tastes, so they changed it to hexadecimal. IBM being IBM—especially back then—meant everyone else followed suit. As I understand it, neither term is etymologically perfect, but well, this note is long enough already. J


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 hexadecimal—even 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.

Key Concept: Regular numbers are called decimal numbers because they are built upon our base-10 system of mathematics. Computers use collections of one-or-zero bits called binary numbers, which can be treated just like regular numbers except that each digit can only be 0 or 1 instead of 0 to 9. Bits in a binary number can be expressed as octal numbers by grouping three bits into an octal digit that ranges from 0 to 7, or taking sets of four bits to create a single hexadecimal digit from 0 to 15. To represent the values 10 through 15 in hexadecimal using a single character, the letters A through F are used.


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.


Previous Topic/Section
Binary Information and Representation: Bits, Bytes, Nibbles, Octets and Characters
Previous Page
Pages in Current Topic/Section
12
3
Next Page
Decimal, Binary, Octal and Hexadecimal Number Conversion
Next Topic/Section

If you find The TCP/IP Guide useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider purchasing a download license of The TCP/IP Guide. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



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.