Lecture
Notes
Number
Systems
The electronic components
used in computer systems can usually be in one of two physical states which can
be represented by a number 0 or 1. These are also the numbers of the
binary system. This is why it is convenient for a computer to use the
binary number system, rather than the more familiar denary number system.
The hexadecimal and octal number systems are also commonly used in computer
systems. These notes look at the binary and hexadecimal number
systems in more detail.
Binary
Number System
Hexadecimal
Number Systems
Number
Base and Place Value
Number Base
The
denary number system has ten symbols, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The
binary system only has two symbols, 0 and 1. The base of a number
system is the number of different symbols it uses. Thus, the denary
system is also referred to as base 10 and the binary number system as base 2.
Place Value
The
position of a number symbol in relation to other number symbols is very
important. The value of a symbol entirely depends on it's position.
This is referred to as place value. In the denary system, each
place is weighted by a power of ten. We have 10^{0}
which is units, 10 ^{1}
which is tens, 10 ^{2}
which is hundreds and so on. Let's illustrate this idea with a table.
10 ^{3}

10 ^{2}

10 ^{1}

10^{0 }

.

10 ^{1}

10 ^{2 }

10 ^{}^{}^{3}

thousands

hundreds

tens

units

decimal point

tenths

hundredths

thousandths

1

2

3

4





4

3

2

1










1

2

3

The
number 1234_{10}
can be expresses as 1
thousand + 2
hundreds + 3 tens
+ 4_{}
units.
This
is an entirely different number value to 4321_{10}
which is 4
thousands + 3
hundreds + 2
tens + 1
unit. So symbol position is all important.
What
about 0.123 .
This can be expressed as no units + 1
tenth + 2
hundredths + 3
thousandths or 0 + 1/10 + 2/100 + 3/1000 .
Note:
10^{0 }is actually equal to 1. Any number raised to the
power of 0 is equal to 1. The fractional part of a number is also determined
by place value, except the power is a negative number, e.g. 10^{1 }means
tenths.

Now,
what about other number systems?
The binary number system has
two symbols, 0
and 1 .
A binary number such as 10_{2}
also has a value depending upon the positioning of the symbols. Now
however, each place is weighted by a
power of two and not a power of ten like the denary system. We
have 2^{0}
which is units, 2 ^{1}
which is twos, 2 ^{2}
which is fours and so on. A place
value table for the binary system would look like...
2^{3}

2 ^{2}

2^{1}

2 ^{0 }

.

2 ^{1}

2^{2 }

2^{}^{3}

8

4

2

1

decimal point

half

quarter

eighth



1

0





So, the binary number 10_{2}_{
} means 1
two +_{ } 0
units.
You should note the binary
number 10_{2} is definitely
not the same as the number 10_{10}
in the denary system. We will see how to convert a number such as 10_{2}_{
} to denary later on.
~Now
try the activity~
Activity
A 

Add
four more columns to the left of the place value table and write in
the correct powers of two.

We
know that 2^{3}
= 2 * 2 * 2 = 8. Convert the following powers of 2 in the same
way

2^{4},2 ^{5} ,2 ^{6} ,2 ^{7}

Add
the values calculated in 2a. to your column headings.

Place the
following in the correct position in your binary table

1 sixty
four + 1 eight + 1 unit

1 one hundred
and twenty eight + 1 eight + 1 unit

What
about the hexadecimal number system?
The hexadecimal number
system has sixteen symbols; I will list them later.
So the base of the hexadecimal
system is 16. Thus,
each place is weighted by a power of sixteen.
A place value table for the
hexadecimal system would look like...
16 ^{3}

16 ^{2}

16 ^{1}

16 ^{0 }

.

16 ^{1}

16 ^{2 }

16^{}^{3}

4096

256

16

1

decimal point

sixteenth

1/256

1/4096



1

0





So, the hexadecimal
number 10_{16 } means
1
sixteen + 0
units.
Again, this number 10_{16}
is not the same as the number 10_{10}
in the denary system. We will see how to convert the number to denary
later on.
~Now
try the activity~
Activity
B 

Draw up a
place value table for the octal number system

Place the
following in the correct position in your octal table

5 sixty
fours + 2 eights + 3 units

7 five
hundred and twelve's + 3 eights + 6 units

Binary
Number System
The
binary symbols are 1 and
0 . Each
digit in a binary system is known as a binary digit or bit. An
example of a binary number is 10110_{2}.
We
have already looked at a place value table for the binary number system.
Let's have another look. The table below is similar to the previous table but I
have left out fractional place values and extended the left place values.
2^{7}

2^{6}

2 ^{5}

2^{4}

2^{3}

2 ^{2}

2^{1}

2 ^{0 }

128

64

32

16

8

4

2

1




1

0

1

1

0

Binary to Denary Conversion
How
do we converting a number such as 10110_{2}
to denary?
Well 10110_{2}
is equivalent to 1×16 + 0×8 +1×4 + 1×2 + 0×1. Which is 16 + 4 + 2 =
22_{10} .
So to
convert a binary number to denary, all we do is multiply each binary digit by
it's place value and add them all together.
Here
are a few more examples.
01101101_{2}
= 0×128 + 1×64 + 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1 = 64 + 32 + 8 + 4
+ 1 = 109_{10}
10010001_{2}
= 1×128 + 0×64 + 0×32 + 1×16 + 0×8 + 0×4 + 0×2 + 1×1 = 128 + 16 + 8 +
1 = 153_{10}
0001110_{2}
= 0×128 + 0×64 + 0×32 + 1×16 + 1×8 + 1×4 + 1×2 + 0×1 = 16 + 8 + 4 + 2
= 30_{10}
~Now
try the activity~
Activity
C 

Convert
the following binary numbers to denary

1100101_{2}
 0111000
_{2}
 0001101
_{2}

11000001_{2}

Denary to Binary Conversion
How
do we convert a denary number to binary?
There
are a few ways of doing this. The simplest way is to use the binary place
value table.
As an
example, suppose we want to convert as 12_{10}
to binary?
Looking
at the place value table, the nearest place value less than or equal to 12
is 8. So we can write a 1
below this place value.
However,
12 minus 8 leaves a
remainder of 4 .
The nearest place value less than or equal to 4
is 4 . So we can
write a 1 below this
place value too. There is no remainder.
Now
we have to fill in any empty place values with zeros, except those to the left
of the leftmost digit 1
.
So, 12_{10}
is equivalent to 1100_{2}
2^{7}

2^{6}

2 ^{5}

2^{4}

2^{3}

2 ^{2}

2^{1}

2 ^{0 }


128

64

32

16

8

4

2

1






1

1

0

0

= 12_{10}

Here
is another example. Let's convert 65_{10}
to binary?
Looking
at the place value table, the nearest place value less than or equal to 67
is 64 . So we can
write a 1 below this
place value.
However,
67 minus 64
leaves a remainder of 3 .
The nearest place value less than or equal to 3
is 2 . So we can
write a 1 below the 2
place value.
Now 3
minus 2 leaves a
remainder of 1 .
The nearest place value less than or equal to 1
is 1 . So we can
write a 1 below this
place value.
Now
we have to fill in any empty place values with zeros, except those to the left
of the leftmost digit 1
.
So, 67_{10}
is equivalent to 1000011_{2}
2^{7}

2^{6}

2 ^{5}

2^{4}

2^{3}

2 ^{2}

2^{1}

2 ^{0 }


128

64

32

16

8

4

2

1



1

0

0

0

0

1

1

= 67 _{10}

~Now
try the activity~
Activity
D 

Convert
the following denary numbers to binary

129_{10}
 40
_{10}
 101
_{10}

253_{10}

Extend
the following table to include the denary numbers 2 to 9 and the
binary equivalents.
Base _{10}

Base _{2}

0

0000

1

0001


Hexadecimal
Number System
The
hexadecimal number system has a base of sixteen. There are 16
symbols. These are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and
F. The six letters A to F are used instead of the denary
numbers 10 to 15.
So,
how do we convert a hexadecimal number to denary and binary?
Hex to Denary Conversion
Suppose
we have the hexadecimal number 3A_{16} .
Well 3A_{16}
is equivalent to 3×16 + A×1 .
Which is 48 + (10×1) = 58_{10} .
So to
convert a hexadecimal number to denary, all we do is multiply each hexadecimal
digit by it's place value and add them all together.
Here
are a few more examples.
B3_{16} = B×16 + 3×1 =
(11×16) + 3 = 179_{10}
5F_{16} = 5×16 + F×1 =
80 + 15 = 95_{10}
CD_{16} = C×16 + D×1 =
12×16 + 13×1 = 85_{10}
~Now
try the activity~
Activity
E 

Convert
the following hexadecimal numbers to denary

AB_{16}
5E_{16}
C0_{16}

FF_{16}

Denary to Hex Conversion
How
do we convert a denary number to hexadecimal?
Using a place value table, this is similar to converting a denary number to
binary.
As an
example, suppose we want to convert as 35 _{10}
to hexadecimal?
Looking
at the place value table, the nearest place value less than or equal to 35
is 16 . 35
divided by 16 is 2
leaving a remainder of 3 .
So we can write a 2
below the place value of 16 .
Now,
considering the remainder of 3 .
The nearest place value less than or equal to 3
is 1. Since we need 3
amounts of 1 we can
write a 3 below
the place value of 1 .
There is no remainder.
So, 35 _{10}
is equivalent to 23_{16}
16 ^{1}

16 ^{0 }


16

1


2

3

= 35_{10}

~Now
try the activity~
Activity
F 

Convert
the following denary numbers to hexadecimal

129_{10}
 40
_{10}
 101
_{10}

253_{10}

Extend
the following table to include the hexadecimal numbers 2 to F and the
binary equivalents.
Base _{16}

Base _{2}

0

0000

1

0001


Why bother with Hexadecimal?
Quite
often it is convenient for programmers to write a computer's binary code in octal
or hexadecimal. Converting octal or hexadecimal numbers to binary is
easier than converting denary to binary. Hexadecimal is used in
preference to octal because computers organise memory in groups of 8 bits (bytes)
and these can be conveniently divided into groups of four bits (nibbles).
Four
bits is easily coded in hexadecimal form.
That's it!!
