Vous êtes sur la page 1sur 14

Expert Reference Series of White Papers

Number Systems
Decoded
Binary, Decimal, and Hexadecimal

1-800-COURSES www.globalknowledge.com
Number Systems Decoded
Binary, Decimal, and Hexadecimal
George Mays, CISSP, CCNA, A+, Security+, Network+

Introduction
In many IT-related fields of study, it is extremely valuable to have a good understanding of the number sys-
tems that are often encountered. For many people, not appreciating things such as binary and hexadecimal is
a stumbling block that keeps them from advancing their knowledge. If you cringe a little bit at the mention of
these topics, then this white paper is definitely for you.

Of course, you may have learned these things many years ago, and you would like a refresher course on num-
ber systems. Or, perhaps you are tired of not understanding the gobbledygook that appears in file dumps, in
routing tables, and in your protocol analysis tools.

Whatever your particular reasons for reading this white paper are, I welcome your attention.

What You Will Learn


We all have an instinctive feel for what numbers are. They are used on a regular basis to identify a particular
house on a street, a channel on the television, or how much to pay for an item.

Numbers are used in a variety of ways; they are most often used to convey a quantity to someone—twelve
chairs, for instance. Numbers are also used in verbal codes, such as 10-4 (ten-four). Sometimes they are part of
an address (such as zip codes).

Despite the intended use, numbers are constructed in the same way and follow the same basic set of rules.
Understanding those rules is the key to advancing your appreciation of numbers.

Several systems of numbers are commonly used in computing circles. These are the decimal, binary, and hexa-
decimal number systems.

These alternative number systems have three things in common: a base number (sometimes called a radix); a
set of digits or numerals to work with; and a positional notation in which the position of a given digit
affects how it is interpreted.

Each number system employs:


• A Base or radix value around which the number system is organized
• A set of Digits or symbols used in forming numbers
• A Positional Notation meaning that the position in which a digit appears conveys information about the
significance or weight of that digit

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 2
Name Base Digits
Decimal 10 0, 1, ...9
Binary 2 0, 1
Hexadecimal 16 0, ...9, A, ...F
Figure A Number System Names, Bases, and Digits

Each number system has a name: Decimal, Binary, and Hexadecimal. Since “hexadecimal” does not flow trip-
pingly off our tongues, we often simply say “Hex” instead.

The decimal number system is encountered most commonly. This is the number system that everyone learns as
a child. As a result, people are most comfortable with decimal.

Everything in a digital world reduces to binary form – everything! The information stored on your disk drive is
stored in a binary form. The information transported across your network is transmitted in a binary form.
Binary is the frank language of computers. And while people may not be as comfortable with binary, comput-
ers love it.

Hexadecimal was invented to intimidate those who are new to information technologies. It is the number sys-
tem that is used to confuse students.

Just kidding, hex is used as a kind of shorthand for binary. Binary numbers tend to be rather long and cumber-
some to type, write down, or say. So hex is used to convey the same information in a compact fashion. It turns
out to be very simple to convert from hex to binary – you will learn how.

The “base” value for a number system is simply the number around which the system is organized. Everything
orbits around the value 10 for base 10 (decimal) numbers. For example, there are ten digits to work with.
Notice that base 2 (binary) numbers have only two digits that can be used.

You do see the pattern, don’t you? If base 10 has ten digits to work with, and base 2 has two digits to work
with, then base 16 must have – how many digits? You guessed it, sixteen. They are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,
B, C, D, E, and F.

The sixteen hex digits sometimes leave people scratching their head because we use the symbols A, B, C, D, E,
and F as digits. These symbols simply represent quantities, as
follows: Hexidecimal Digit Decimal Value
A 10
These symbols are letters of the alphabet. You know that; I
know that. However, in hexadecimal numbers, they are digits, B 11
perfectly good digits. C 12
D 13
Someone might point out to you that there are 3 windows in
the classroom. The digit 3 conjures up something in your brain – E 14
the notion of the quantity 3. In like manner, I could note that F 15
there are B desks in the classroom. That should make you think
Figure B. Hex Digit Values in Decimal
of the quantity 11, hence 11 desks are present.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 3
Base 10
Let’s consider a simple base 10 number, 1585. The number is structured in a very orderly way. To begin with,
note that the digits all come from the decimal symbol set (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) and that the symbol 5
appears twice in the number.

We us the term “positional notation” to reflect the fact


that the 5 appearing in the rightmost position is interpret- 1000s 100s 8s 1s
ed differently than the one appearing two positions to the
1 5 8 5
left. That is to say that the position in which a digit
appears has everything to do with the significance or 1000 500 80 5 = 1585
weight that we attach to it. In this case the rightmost 5
implies 5 ones and that to the left implies 5 hundreds. Figure C. Positional Notation

Take a look at Figure C. It is obvious to most people how decimal values are organized. The rightmost position
is the “ones place.” To the left is the “tens place.” To the left again is the “hundreds place,” and so on. Notice
that each “place” or position carries a weight 10 times the one to its right. (Just what you’d expect? This is the
base 10 number system, after all.)

A careful analysis of our example value reveals that the number 1585 is intended to convey to us, as readers
of the number, a quantity that is comprised of 1 thousand, 5 hundreds, 8 tens, and 5 ones.

That is pretty simple, right? There are no surprises here. This is stuff from the third grade in elementary school.

But what about the other number systems? They must be different somehow.

Base 2
Let us now examine a binary example, 1001. Start by noting that the digits come from the smaller binary sym-
bol set, just 0s and 1s. And, in a manner similar to the previous example, the symbol 1 appears twice.

The rightmost position in a binary number is the ones 8s 4s 2s 1s


place, as it was in the decimal example. (See Figure D.)
1 0 0 1
But as we progress to the left, each position carries a
weight that is 2 times the one on its right. Thus we 8 0 0 1 =9
observe the ones place, twos place, fours place, eights
Figure D. Binary Notation
place, and so on.

So in binary values you have only 2 digits to work with, zeroes and ones, and the “places” in the numbers are
each weighted 2 times the position to their right. That’s why it is called the base 2 numbering system.

Analyzing our example value (1001), we discover that this number is intended to convey to the reader a quan-
tity comprised of 1 eight and 1 one, or 9 (in decimal).

Base 16
Now consider a hexadecimal example, 12A. Just as with the other number systems, the digits come from the
allowable symbol set, in this case 0 through 9 and A through F.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 4
A few observations are in order before proceeding. First, 4096s 256s 16s 1s
some people seem to think that there is some difference
between a lower case “a” and an upper case “A.” There 1 2 A
is not. You will see both cases regularly and the differ-
ence does not matter. Second, as noted previously, some 256 32 10 = 298
people cringe seeing letters of the alphabet in numbers.
Figure E. Hex Notation
Put your confusion aside. Just as the regular-old-every-
day digit 5 makes you think of the number of fingers on
your hand, the hex digit C should make you think of the number of doughnuts that come in a package. (Of
course, a baker’s dozen would be a hex D.)

Consider Figure E. The rightmost position is again the 1s place. What is different is that as you move to the
left, each position carries a weight that is 16 (get it, base 16) times the position on the right. So you end up
with a progression like 1, 16, 256, 4096, and so on.

Our example value then, 12A, denotes 1 two-hundred-fifty-six, 2 sixteen’s, and A ones. With a little quick men-
tal gymnastics one realizes the A ones means 10 (decimal) ones to mere mortals. So this hex value conveys the
notion of 256 plus 32 plus 10, or the quantity 298 decimal.

Intermediate Summary
You have learned that three number systems are used commonly in IT: decimal; binary; and hexadecimal.

Also, these number systems are structured in a similar manner. They each have a “base” value of 10, 2, and
16, respectively. And, each has a limited symbol set (digits) that can be used in constructing numbers. For deci-
mal the set consists of the digits 0…9, for binary there are only 0s and 1s, and for hex the digits 0…9 and
A…F are used.

Each of the number systems employs a positional notation in which a given digit’s position within a number
dictates the weight that we associate with it. The rightmost position is always the 1s place. As you move to the
left, the positions carry a weight that is the base value times its right-hand neighbor. The progressions 1, 10,
100, and so on appear for decimal numbers. With binary numbers we see a progression like 1, 2, 4, 8, 16, 32,
etc. And for hex we observe the progression 1, 16, 256, 4096, and so on.

Recognizing the Number System


How do you know whether the value 101 is decimal, binary, or hex? You don’t, unless there is additional clari-
fication provided to you.

The number system being used is very often conveyed by the context in which you observe the number. By
default, we tend to assume that a number is decimal unless otherwise indicated. But if you were reading a
paper on binary masking (whatever that is) you might reasonably assume that the value is binary. You get the
idea.

Mathematicians use subscripts to indicate the number system. So if you see 10110 then you are dealing with
101 base 10, decimal. The value 1012 means that this is a binary (base 2) value. And, as you would expect,
10116 implies a hexadecimal (base 16) value.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 5
Programmers have various notations that you will encounter as well. It is extremely common to encounter a
number like 0x101. The 0x prefix is C-programmer-speak for a hex constant. So this pops up a lot.

Assembly language programmers have their own notations. For example, in such a program you might
encounter 101h, meaning a hex value. Similarly, 101b implies a binary value..

Decimal to Binary Conversion


Converting a decimal value to binary is like making change at a cash register. Except, instead of using 1, 10,
and 100 dollar bills you use “Bin-o-Bucks”*. The denominations are 1, 2, 4, 8, 16, and so on.

Make yourself a cheat-sheet like this:

128 64 32 16 8 4 2 1

How would you “pay” somebody 18 in bin-o-bucks? You would give them 1 sixteen and 1 two. Like this:

128 64 32 16 8 4 2 1
1 1

And since you are not paying out any eights, fours, or ones, just put a zero in those positions to indicate that
fact. You end up with:

128 64 32 16 8 4 2 1
1 0 0 1 0

The binary value 10010 represents the decimal value 18. Easy. Try it again by converting the value 3710 to bin-
o-bucks. (Here is your cheat-sheet.)

128 64 32 16 8 4 2 1

Now check your result. To pay out 37 you would use 1 thirty-two, 1 four, and 1 one. Get it? 32 + 4 + 1 = 37.
You answer should look like:

128 64 32 16 8 4 2 1
1 0 0 1 0 1

Do not make this more complicated than it is. Conversion from decimal to binary is, in fact, this simple. If you
practice just a little bit, then you can easily become quite good at this.

Binary to Decimal Conversion


Simply extend the change-making analogy that was just described. For example, if someone just handed you
an 8 dollar bill and a 4 dollar bill then they just gave you:

128 64 32 16 8 4 2 1
1 1 0 0

And 8 + 4 is 12. So a binary 1100 is the representation for a decimal 12.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 6
Try this again for yourself. The customer just handed you a 64, an eight and a two. Here is your cheat sheet:

128 64 32 16 8 4 2 1

Your result should look like this:

128 64 32 16 8 4 2 1
1 0 0 1 0 1 0

64 + 8 + 2 = 74. So you just received 74 bucks.

Decimal to Hexadecimal
Stick with the change-making analogy. Only replace the bin-o-bucks with “Hex-A-Bucks”*. The denominations
of the bills are 1s, 16s, 256s, and 4096s. Your cheat-sheet looks like this:

4096 256 16 1

If you had to pay out 3510 dollars, that would call for the use of two 16s and three 1s.

4096 256 16 1
2 3

So the value 23 is the hex representation of the decimal value 35.

Try your hand at this. You need to pay out 2510 in hex-a-bucks. What do you get? Here is your cheat-sheet:

4096 256 16 1

Check your answer. You should have gotten this:

4096 256 16 1
1 9

The answer is one 16 plus nine 1s. 16 + 9 = 25.

Hexadecimal to Decimal
Extend the hex-a-bucks analogy from the previous exercises to convert in the opposite direction, from hex to
decimal this time.

Start with you hex cheat-sheet:

4096 256 16 1

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 7
Now, let’s say that you are asked to convert 5416 to base 10. Plug 54 into your cheat-sheet. You get:

4096 256 16 1
5 4

That is five 16s and four 1s. 5 x 16 = 80, add the 4 x 1, you get 84 decimal.

Can you do this one: 1E16 = ?10. Here is your cheat sheet:

4096 256 16 1
1 E

That would be 1 sixteen and E ones. Recall that the symbol E depicts the quantity 14 in decimal. So that is one
16 and 1410 1s; 16 + 14 is 30 decimal.

Hexadecimal to Binary
Hex to binary is very easy. Conversion is done using a simple substitution technique. Each hex digit converts to
four binary digits. Here is what the hex digits look like in binary:

Hex Binary Hex Binary Hex Binary Hex Binary


0 0000 4 0100 8 1000 C 1100
1 0001 5 0101 9 1001 D 1101
2 0010 6 0110 A 1010 E 1110
3 0011 7 0111 B 1011 F 1111

Do you understand where these numbers come from? Let’s take a couple of them and analyze them to be sure
that you appreciate what is going on here, starting with the hex 6. What does 616 look like in binary?

8 4 2 1
0 1 1 0

Notice the 4 and the 2 bit (binary digit) positions are set to 1. The other positions are 0. One 4 plus one 2
equals 6.

Or how about the 916 table entry? In binary it looks like:

8 4 2 1
1 0 0 1

That’s one 8 plus one 1, or 9.

Now that you know how this substitution table was constructed, let’s convert a sample hex value, how about
B8, to binary. Simply write binary 1011 in place of the hex B followed by binary 1000 in place of the 8. You get
1011 1000 binary. (I put a space in there for clarity – binary numbers don’t actually have spaces in them.)

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 8
Hex value to be converted: B8
Substitute 1011 for hex B: 1011 8
Substitute 1000 for hex 8: 1011 1000

Try another example. 4F116 = ?2. In place of the 4 write 0100, in place of the F write 1111, and in place of the
1 write 0001. You get 0100 1111 0001.

Hex value to be converted: 4F1


Substitute 0100 for hex 4: 0100 F1
Substitute 1111 for hex F: 0100 1111 1
Substitute 0001 for hex 1: 0100 1111 0001

Binary to Hexadecimal
Converting a binary value to hex is similarly easy. Just reverse the substitution process described above.
Working from right to left in the binary value, substitute one hex digit for each group of four binary digits. An
example is the best way to appreciate this.

Binary value to be converted: 10110110


Identify groups of four bits: 1011 0110
Substitute hex 6 for 0110: 6
Substitute hex B for 1011: B 6

If the number of binary digits (bits) is not a multiple of four, then just pad it on the left with additional zeroes.
For example:

Binary value to be converted: 1010110110


Identify groups of four bits: 10 1011 0110
Pad the left with zero bits: 0010 1011 0110
Substitute hex 6 for 0110: 6
Substitute hex B for 1011: 2 B 6
Substitute hex 2 for 0010:

Helpful Tools for Working with Number Systems


There is no shortage of tools to help you work with the
number systems. Though hardly the best tool, the Windows
Calculator can be useful.

On a Windows system, begin at the Start button, choose All


Programs, then Accessories. Finally, choose Calculator. The
familiar Windows Calculator will pop up. You are probably
used to the wimpy balance-your-checkbook mode that
appears above. But if you pick the View pull-down menu
and select Scientific, the fancier calculator features are
revealed.

Figure F. Calculator

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 9
Toward the upper left of the calculator you will see a
group box that contains four radio buttons: Hex, Dec,
Oct, and Bin. The Bin button has been clicked in the
figure above and a binary value entered into the
calculator: 1010110110.

Figure G. Hex Calculator

Clicking on the Hex button, the calculator converts the


binary value to hex: 2B6. You can use this technique to
convert between any of the supported number sys-
tems. If you are curious, Oct stands for the octal, or
base 8, number system.

Figure H. Hex Conversion

Another tool that you might like is my Number Converter. You can obtain this from my website: HYPERLINK
"http://www.gwmays.com" www.gwmays.com. Just follow the link to Number Converter Version 2. It can be
downloaded as a .zip file or, more conveniently, as a self-extracting zip, the .exe.

This tool has only one input field at


the upper left. The program con-
verts any number that you enter
here to each of the number sys-
tems that we learned about. A
note: the Number Converter
“guesses” what kind of value you
entered; you may have to click the
Type of Input Value button to cor-
rect the Number Converter if it
guesses wrong.

Figure I. Number Converter 2.0

Another tried and true tool is a conversion chart. The conversion chart on the next page covers all values
between 0 and 255 decimal.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 10
Decimal Binary Hex Decimal Binary Hex Decimal Binary Hex Decimal Binary Hex
0 0000 0000 00h 64 0100 0000 40h 128 1000 0000 80h 192 1100 0000 C0h
1 0000 0001 01h 65 0100 0001 41h 129 1000 0001 81h 193 1100 0001 C1h
2 0000 0010 02h 66 0100 0010 42h 130 1000 0010 82h 194 1100 0010 C2h
3 0000 0011 03h 67 0100 0011 43h 131 1000 0011 83h 195 1100 0011 C3h
4 0000 0100 04h 68 0100 0100 44h 132 1000 0100 84h 196 1100 0100 C4h
5 0000 0101 05h 69 0100 0101 45h 133 1000 0101 85h 197 1100 0101 C5h
6 0000 0110 06h 70 0100 0110 46h 134 1000 0110 86h 198 1100 0110 C6h
7 0000 0111 07h 71 0100 0111 47h 135 1000 0111 87h 199 1100 0111 C7h
8 0000 1000 08h 72 0100 1000 48h 136 1000 1000 88h 200 1100 1000 C8h
9 0000 1001 09h 73 0100 1001 49h 137 1000 1001 89h 201 1100 1001 C9h
10 0000 1010 0Ah 74 0100 1010 4Ah 138 1000 1010 8Ah 202 1100 1010 CAh
11 0000 1011 0Bh 75 0100 1011 4Bh 139 1000 1011 8Bh 203 1100 1011 CBh
12 0000 1100 0Ch 76 0100 1100 4Ch 140 1000 1100 8Ch 204 1100 1100 CCh
13 0000 1101 0Dh 77 0100 1101 4Dh 141 1000 1101 8Dh 205 1100 1101 CDh
14 0000 1110 0Eh 78 0100 1110 4Eh 142 1000 1110 8Eh 206 1100 1110 CEh
15 0000 1111 0Fh 79 0100 1111 4Fh 143 1000 1111 8Fh 207 1100 1111 CFh
16 0001 0000 10h 80 0101 0000 50h 144 1001 0000 90h 208 1101 0000 D0h
17 0001 0001 11h 81 0101 0001 51h 145 1001 0001 91h 209 1101 0001 D1h
18 0001 0010 12h 82 0101 0010 52h 146 1001 0010 92h 210 1101 0010 D2h
19 0001 0011 13h 83 0101 0011 53h 147 1001 0011 93h 211 1101 0011 D3h
20 0001 0100 14h 84 0101 0100 54h 148 1001 0100 94h 212 1101 0100 D4h
21 0001 0101 15h 85 0101 0101 55h 149 1001 0101 95h 213 1101 0101 D5h
22 0001 0110 16h 86 0101 0110 56h 150 1001 0110 96h 214 1101 0110 D6h
23 0001 0111 17h 87 0101 0111 57h 151 1001 0111 97h 215 1101 0111 D7h
24 0001 1000 18h 88 0101 1000 58h 152 1001 1000 98h 216 1101 1000 D8h
25 0001 1001 19h 89 0101 1001 59h 153 1001 1001 99h 217 1101 1001 D9h
26 0001 1010 1Ah 90 0101 1010 5Ah 154 1001 1010 9Ah 218 1101 1010 DAh
27 0001 1011 1Bh 91 0101 1011 5Bh 155 1001 1011 9Bh 219 1101 1011 DBh
28 0001 1100 1Ch 92 0101 1100 5Ch 156 1001 1100 9Ch 220 1101 1100 DCh
29 0001 1101 1Dh 93 0101 1101 5Dh 157 1001 1101 9Dh 221 1101 1101 DDh
30 0001 1110 1Eh 94 0101 1110 5Eh 158 1001 1110 9Eh 222 1101 1110 DEh
31 0001 1111 1Fh 95 0101 1111 5Fh 159 1001 1111 9Fh 223 1101 1111 DFh
32 0010 0000 20h 96 0110 0000 60h 160 1010 0000 A0h 224 1110 0000 E0h
33 0010 0001 21h 97 0110 0001 61h 161 1010 0001 A1h 225 1110 0001 E1h
34 0010 0010 22h 98 0110 0010 62h 162 1010 0010 A2h 226 1110 0010 E2h
35 0010 0011 23h 99 0110 0011 63h 163 1010 0011 A3h 227 1110 0011 E3h
36 0010 0100 24h 100 0110 0100 64h 164 1010 0100 A4h 228 1110 0100 E4h
37 0010 0101 25h 101 0110 0101 65h 165 1010 0101 A5h 229 1110 0101 E5h
38 0010 0110 26h 102 0110 0110 66h 166 1010 0110 A6h 230 1110 0110 E6h
39 0010 0111 27h 103 0110 0111 67h 167 1010 0111 A7h 231 1110 0111 E7h
40 0010 1000 28h 104 0110 1000 68h 168 1010 1000 A8h 232 1110 1000 E8h
41 0010 1001 29h 105 0110 1001 69h 169 1010 1001 A9h 233 1110 1001 E9h
42 0010 1010 2Ah 106 0110 1010 6Ah 170 1010 1010 AAh 234 1110 1010 EAh
43 0010 1011 2Bh 107 0110 1011 6Bh 171 1010 1011 ABh 235 1110 1011 EBh
44 0010 1100 2Ch 108 0110 1100 6Ch 172 1010 1100 ACh 236 1110 1100 ECh
45 0010 1101 2Dh 109 0110 1101 6Dh 173 1010 1101 ADh 237 1110 1101 EDh
46 0010 1110 2Eh 110 0110 1110 6Eh 174 1010 1110 AEh 238 1110 1110 EEh
47 0010 1111 2Fh 111 0110 1111 6Fh 175 1010 1111 AFh 239 1110 1111 EFh
48 0011 0000 30h 112 0111 0000 70h 176 1011 0000 B0h 240 1111 0000 F0h
49 0011 0001 31h 113 0111 0001 71h 177 1011 0001 B1h 241 1111 0001 F1h
50 0011 0010 32h 114 0111 0010 72h 178 1011 0010 B2h 242 1111 0010 F2h
51 0011 0011 33h 115 0111 0011 73h 179 1011 0011 B3h 243 1111 0011 F3h
52 0011 0100 34h 116 0111 0100 74h 180 1011 0100 B4h 244 1111 0100 F4h
53 0011 0101 35h 117 0111 0101 75h 181 1011 0101 B5h 245 1111 0101 F5h
54 0011 0110 36h 118 0111 0110 76h 182 1011 0110 B6h 246 1111 0110 F6h
55 0011 0111 37h 119 0111 0111 77h 183 1011 0111 B7h 247 1111 0111 F7h
56 0011 1000 38h 120 0111 1000 78h 184 1011 1000 B8h 248 1111 1000 F8h
57 0011 1001 39h 121 0111 1001 79h 185 1011 1001 B9h 249 1111 1001 F9h
58 0011 1010 3Ah 122 0111 1010 7Ah 186 1011 1010 BAh 250 1111 1010 FAh
59 0011 1011 3Bh 123 0111 1011 7Bh 187 1011 1011 BBh 251 1111 1011 FBh
60 0011 1100 3Ch 124 0111 1100 7Ch 188 1011 1100 BCh 252 1111 1100 FCh
61 0011 1101 3Dh 125 0111 1101 7Dh 189 1011 1101 BDh 253 1111 1101 FDh
62 0011 1110 3Eh 126 0111 1110 7Eh 190 1011 1110 BEh 254 1111 1110 FEh
63 0011 1111 3Fh 127 0111 1111 7Fh 191 1011 1111 BFh 255 1111 1111 FFh

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 11
Some Ways To Use This Knowledge
You might question the usefulness of what you just learned. Well, let us consider a few practical examples of
how one might apply this knowledge.

Case 1 – IP Addresses
IP addresses are really 32 bit binary numbers. But we write them using what is called dotted-decimal notation.
Consider this IP address:

10.1.1.5

In binary, that appears as follows:

00001010 00000001 00000001 00000101

The spaces are just for clarity. Notice that the leftmost eight bits has the 8 and 2 bits on – that’s the 10. Each
of the next two groups of eight bits only have the 1 bit on – that is the 1s you see in the address. And the last
group of eight bits has the 4 and 1 bits on – which is, of course, the 5.

Do you see how this works? Each of those decimal numbers that appears in the dotted-decimal address con-
verts to an 8 bit binary number. Collectively, the four groups of eight bits form the 32 bit IP address.

Case 2 – Subnet Masks


Subnet masks are also 32 bit binary numbers, also written in dotted-decimal notation. Here is an example:

255.255.255.240

In binary, that mask is as follows:

11111111 11111111 11111111 11110000

The value 255 decimal converts to 11111111 in binary. If you are in doubt, add 128+64+32+16+8+4+2+1;
you get 255. Consider the 240. “Pay” out 240 in bin-o-bucks. That would be 128+64+32+16. Those are the
bits on in that last group of eight bits; the others (8, 4, 2, and 1) are zero. Maybe it would be clearer to see it
this way:

Bin-o-Bucks
128 64 32 16 8 4 2 1 Decimal
1 1 1 1 1 1 1 1 255
1 1 1 1 0 0 0 0 240

Case 3 – Character Codes (e.g. ASCII)


Imagine looking at an ASCII code chart like the partial one in Figure J. These codes are actually binary values
that we use to represent each of the commonly used letters, digits, and special characters. What is the ASCII
code for “f”?

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 12
It is easy to spot – “f” is encoded as the hex value 66. Okay, Char Dec Oct Hex
but what is the binary code; that is not shown in the table. - 96 0140 0x60
a 97 0141 0x61
Hex Digit Binary b 98 0142 0x62
6 8 4 2 1
c 99 0143 0x63
0 1 1 0
d 100 0144 0x64
e 101 0145 0x65
Simply convert the hex 66 to binary. Each of the 6s translates
to binary 0110. So your answer is 0110 0110. f 102 0146 0x66
g 103 0147 0x67
h 104 0150 0x68
i 105 0151 0x69
Figure J. Conversion Table
Case 4 – Protocol Analysis
You have captured an Ethernet frame traversing the network and have dumped it out. The length of the frame
is sometimes encoded in the 13th and 14th bytes of the Ethernet header. See Figure K.

0000 01 80 c2 00 00 00 00 04 e2 de ff ff 00 26 42 42 ........ .....&BB


0010 03 00 00 00 00 00 80 00 00 04 e2 de ff f8 00 00 ........ ........
0020 00 00 80 00 00 04 e2 de ff f8 80 08 00 00 14 00 ........ ........
0030 02 00 0f 00 00 00 00 00 00 00 00 00 00 00 02 00 ........ ........

Figure K. Ethernet dump

The dump shows the hex value 0026 in that part of the header. What is that in decimal?

4096 256 16 1
2 6

Simple, two 16s plus six 1s, 38 bytes.

Conclusion
You have learned that three systems of numbers are often encountered in IT-related studies. They are decimal,
binary, and hexadecimal.

People like decimal. Computers like binary. Neither likes hexadecimal – hex is just a great shorthand for binary.

All of the number systems have three things in common:


• Each has a “base” value
• Each system has a limited number of “digits” to work with
• They all rely upon “positional notation” to convey the significance of the digits within a given number

Conversion between these systems is a common chore. You can do it manually by applying your knowledge of
these number systems. Or, you might prefer to use one of the tools, like calculators or reference tables, to
assist in this.

Good luck working with these numbers in the future.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 13
Learn More
Learn more about how you can improve productivity, enhance efficiency, and sharpen your competitive edge.
Check out the following Global Knowledge courses:
Network+ Boot Camp
Understanding Networking Fundamentals
TCP/IP Networking

For more information or to register, visit www.globalknowledge..com or call 1-800-COURSES to speak with a
sales representative.

Our courses and enhanced, hands-on labs offer practical skills and tips that you can immediately put to use.
Our expert instructors draw upon their experiences to help you understand key concepts and how to apply
them to your specific work situation. Choose from our more than 700 courses, delivered through Classrooms,
e-Learning, and On-site sessions, to meet your IT and management training needs.

About the Author


George Mays has over 35 years’ experience in computing, data communications, and networking. His experi-
ence includes mainframe systems programmer, Fortune 500 DBA, management of systems programming, data
communications, IT operations, engineering, software development, and networking. He is also the author and
course director for Global Knowledge’s Network+ Boot Camp and has contributed to several hacking and
security books. George holds various industry certifications including CISSP, CCNA, A+, Network+, Security+,
INet+.

Past certification: MCSE. He is an instructor in TCP/IP, Troubleshooting, Network Protocols, Network


Fundamentals, A+, Security+ and CISSP. In addition to teaching for Global Knowledge, Mr. Mays also acts as a
consultant in the fields of general networking and security.

*Bin-o-Bucks and Hex-a-Bucks are the intellectual property of G.W. Mays & Associates, Inc. of Helotes, Texas. All
Rights Reserved.

Copyright ©2007 Global Knowledge Training LLC. All rights reserved. Page 14

Vous aimerez peut-être aussi