Pages

Numbering Systems


The binary andhexidecimal numbering systems have always presented a huge problem for moststudents. Actually, if I look through the different computer books and studymaterial that try to explain the subject, its really no wonder. I have foundinformation that explains it using boxes, building blocks, candles, cars.... Ihave no idea what this is myself. In fact, just as you start to think you'vegot a handle on it, you read another explanation that tends to confuse youentirely. So, at the risk of baffling you completely, I'll try to explain,using another method, the method my grade 2 teacher (or maybe grade 3, I can't remember)taught me to understand decimal numbers of more than 1 digit. This doesn't workso well for hexidecimal, because the numbers get real large real quick. But wecan check it out.

First thing toremember... is that you don't need to learn to count. Unless you're attemptingto understand low level programming, learning binary provides you with twothings:

- comprehension of how your computer stores information, with a betterunderstanding of bits, bytes, kilobytes, etc...

- an easy method of converting between decimal and hexidecimal. You don't haveto learn to count in hexidecimal either, but I/O addresses and memory addressesare given in hex and sometimes you can resolve device conflicts by being ableto tell if addresses overlap.

So, my suggestion isto find a conversion method that you can understand, bookmark it or keep it ina file, then forget about it. Look it up again on the rare occasion that youmight need it. (By the way, my favorite conversion method is a calculator).

All that being said,lets get back to grade 2.

Decimal(base 10)

The decimal numbering system is the system we all use in our everyday work. Itconsists of 10 digits (hence the name decimal). The digits, from smallest tolargest are:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Now, any number canbe broken down into columns. From right to left, the first column is the 1'scolumn, then the 10's column, then the 100's, then the 1000's, etc..

Let's look at the number 137:

Thousands
Hundreds
Tens
Ones
0
1
3
7



0 X 1000 = 0 (0 thousands)
1 X 100 = 100 (1hundreds)
3 X 10 = 30 (3 tens)
7 X 1 = 7 (7 ones)
0+100 + 30 + 7 = 137

If you don'tunderstand it this far, go back over it until you do, or get some help.

OK, lets try thenumber 77:

Thousands
Hundreds
Tens
Ones
0
0
7
7




0 X 1000 = 0 (0thousands)
0 X 100 = 0 (0 hundreds)
7 X 10 = 70 (7 tens)
7 X 1 = 7 (7 ones)
0+0+70 + 7 = 77

If you understandthis far, go on to the next page for binary.

Binary(base 2)

Your computer works using the binary numbering system. Thisis because a computer can only recognize two states, the presence of anelectrical charge or the absence of an electrical charge. In other words, on oroff.

The binary numberingsystem is ideal for representing these two states because it consists of onlytwo digits. The digits, from smallest to largest are:

0, 1.
0 represents theabsence of an electrical charge or 'off'.
1 represents thepresence of an electrical charge or 'on'.
(Now you can understandwhy the power switch on your computer is labelled as O/1).

Once again, anynumber can be broken down into columns. Each column is a placeholder. Using thebinary numbering system, from right to left, the first column is the 1'scolumn, then the 2's column, then the 4's, then the 8's, then the 16's column,then the 32's column, etc..

Let's look at the number 137 again:

One
hundred
twenty-eights
Sixty-
fours
Thirty-
twos
Sixteens
Eights
Fours
Twos
Ones
1
0
0
0
1
0
0
1

1 X 128 = 128 (1 onehundred twenty-eights)
0 X 64 = 0 (0sixty-fours)
0 X 32 = 0 (0thirty-twos)
0 X 16 =0 (0sixteens)
1 X 8 = 8 (1 eights)
0 X 4 = 0 (0 fours)
0 X 2 = 0 (0 twos)
1 X 1 = 1 (1 ones)
128 + 0 + 0 + 0 + 8 +0 + 0 + 1 = 137

Thus, the binary number 10001001 is equal to 137 decimal.

A single digit (0 or1) is called a 'bit' (binary digit).

The table above contains 8 bits. Each column can containeither a 1 or a 0 ( 'cause there is only 2 digits in the binary numberingsystem). So, as you can see, it takes 8 bits to represent the decimal number137.
Make sense?

If you don't understand it this far, go back over it until you do, or get somehelp.

OK, lets try thenumber 77:

One
hundred
twenty-eights
Sixty-
fours
Thirty-
twos
Sixteens
Eights
Fours
Twos
Ones
0
1
0
0
1
1
0
1

0 X 128 = 0 (0 onehundred twenty-eights)
1 X 64 = 64 (1sixty-fours)
0 X 32 = 0 (0thirty-twos)
0 X 16 =0 (0sixteens)
1 X 8 = 8 (1 eights)
1 X 4 = 4 (1 fours)
0 X 2 = 0 (0 twos)
1 X 1 = 1 (1 ones)

0 + 64 + 0 + 0 + 8 +4 + 0 + 1 = 77

Thus, the binary number 01001101 is equal to 77 decimal.

Any character thatyou type (including spaces), and any character you can see on your screen,takes 8 bits for your computer to produce. Eight bits associatedtogether are called a 'byte'. A byte is the real building block ofcomputer information. This can form a single character. A character can be anumber, letter, or symbol. The amount of information a device can store is measuredin bytes. Because of this, most numbers and sizes reported by the computer areevenly divisible by 8.

Multiple bytes associated together are often called a 'word'.


8 bits = 1 byte
1024 bytes = 1kilobyte (Kb)
1024 kilobytes = 1megabyte (Mb) (1,048,576 characters or bytes)
1024 megabytes = 1gigabyte (Gb)

These numbers areoften rounded off for ease of calculation.

You might see 1megabyte represented as a million bytes (1,000,000 characters), or 1000kilobytes.

If you understandthis far, go on to the next page for hexidecimal.

Hexidecimal(base 16)

Remember, that eight bits make a byte, and that it takeseight bits to store a single character in the computer. 1024 bytes make akilobyte and 1024 is divisible by eight. Seems like the magic number forcomputers is eight. The thing is, even relatively low binary numbers can belong and cumbersome.
The hexidecimalnumbering system consists of sixteen digits. The digits, from smallest tolargest are:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

Once again, anynumber can be broken down into columns. Each column is a placeholder. Using thehexidecimal numbering system, from right to left, the first column is the 1'scolumn, then the 16's column, then the 256's, then the 4096's, then the 65536'scolumn, etc.. Because you multiply the number in each previous column by 16,you can see that the numbers get very large and scary very quickly.

Here's the number137:

65536
4096
256
16
1
8
9

0 X 65536 = 0 (0sixty-five thousand five hundred thirty-sixes)
0 X 4096 = 0 (0 fourthousand ninety-sixes)
8 X 16 = 128
9 X 1 = 9
0 + 0 + 128 + 9 = 137
Decimal 137 = 89h(Hexidecimal)

Here's an easier way.Any group of 4 binary digits can represent up to sixteen values. A singlehexidecimal digit can stand for any one of the 16 values that can berepresented by any 4 bit binary number. In other words, break any binary numberinto groups of 4 bits. Use a chart (or if your memory is good you can use that)to find the proper hex number that represents those four bits. I know, itsounds a bit confusing, so let's do a couple.

Here's the chart:

Decimal
Hex
Binary
0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111

Lets try the number137 again:
From the previouspage, we know that the binary
equivalent is10001001.

Break this into 2groups of 4 bits, [1000][1001]
Use the chart to findHex numbers
[1000] = 8h
[1001] = 9h

Decimal = 137

Binary equivalent =10001001
Hexidecimalequivalent = 89h

Make sense?


If you don't understand it this far, go back over it until you do, or get somehelp.
Hexidecimal numbersare followed by a lowercase 'h' to designate them as hex.


One thing to keep inmind is that if you have a binary number like
10 (2 decimal), you can add zeros to the left to make it afull 4 bit number. eg. 0010

Decimal
Hex
Binary
0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111
OK, lets try thenumber 77:
We know from theprevious page that the binary equivalent is 01001101.
Let's break that intotwo groups of 4 bits.
[0100][1101].
Now let's check thechart.
[0100] = 4h
[1101] = Dh
Decimal = 77
Binary equivalent =01001101
Hexidecimalequivalent = 4Dh


Check it!

65536
4096
256
16
1
4
D

0 X 65536 = 0 (0 sixty-five thousandfive hundred thirty-sixes)
0 X 4096 = 0 (0 four thousandninety-sixes)
0 X 256 = 0 (0 two hundred fifty-sixes)

4 X 16 = 64 (4 sixteens)
D X 1 = 13 (D ones) (remember we'reusing hex, D = 13 decimal)
0 +0 + 0 + 64 + 13 = 77 decimal

Now, if all this hascompletely confused you, don't worry. Remember, this isn't your only resource.Check out your books, the internet, ask someone else. Once you've found amethod that you can understand, keep it in mind (or maybe a safer place). Ifyou need to convert a number, refer to it, make the conversion, then lock itaway again.


Decimal, Hexidecimal, and Binary Values

Digit Values


Decimal
100,000
10,000
1,000
100
10
1

Binary
512
256
128
64
32
16
8
4
2
1

Hexidecimal
65,536
4,096
256
16
1


You didn't think youwere getting away that easy, did you? You have to do a little practise beforeyou can lock it away entirely!
The digit values are above and your chart is down below. See if you can fill inthe missing values.


Decimal
Hex
Binary
0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111
Decimal
Hex
Binary
163
?
10100011
?
2Fh
?
?
30h
00110000
3840
?
?
?
?
10000000000
?
4ACh
?