Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

WHAT ARE NUMBER BASES?

- Number bases are a way of counting and representing numbers


- The commonly used number bases include:
 Decimal/Denary Number Base (Base 10)
 Binary Number Base (Base 2)
 Octal Number Base (Base 8)
 Hexadecimal Number Base (Base 16)
- Every number base has the following characteristics:
 The base defines the number of different symbols used in the number base. For
example base 10 (denary) can accommodate 10 symbols/digits and base 16 (hex) can
accommodate 16 symbols.
 The largest value of a digit is always one digit less than the Base. For example, the
largest digit in octal number base is 7 (8 — 1).
- The design of a computer is dependent upon the number bases

TYPES OF NUMBER BASES

a. Decimal / Denary Number Base


- This is the most commonly used number base in our day to day life
- The base of the decimal number is 10 (e.g. 3810, 9710, 510)
- There are ten unique symbols in the Decimal number base
- The symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9
- The maximum or largest value of digit is 9

Counting numbers in the decimal base


- The table and the number line below shows how the numbers are counted (from left to
right):
Table 1.1: Sequence of Decimal Number Base

Iteration 1 0 1 2 3 4 5 6 7 8 9
Iteration 2 10 11 12 13 14 15 16 17 18 19
Iteration 3 20 21 22 23 24 25 26 27 28 29
Iteration 4 30 31 32 33 34 35 36 37 38 39
Figure 1.1: Decimal base number line

| | | | | | | | | | | | | | | | | | | | | | | | |

-4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

- Any number in decimal number base can be represented by using the ten symbols (0-9)
arranged in various positions.
- Each position is expressed in the power of 10. See Example 1.1
- If the fractional part exists, their positional values are expressed in the negative powers
of 10. See Example 1.2

Examples of positional values in decimal base

Example 1.1 Example 1.2


The number 5926 can be written as: The number 135.24 can be written as:

5926 135.24
= 5 x 10 + 9 x 10 + 2 x 10 + 6 x 10
3 2 1 0 = 1 x 102 + 3 x 101 + 5 x 100 + 2 x 10-1 + 4 x 10-2
= 5000 + 900 + 20 + 6 = 100 + 30 + 5 + 0.2 + 0.04

From 5926, we can see that the positional From 135.24, we can see that the positional
value of 9 is 2 (from 102) value of 4 is -2 (from 10-2)
Also in the number 5926, 5 is the Most Also in the number 135.24, 1 is the Most
Significant Digit and 6 is the Least Significant Digit and 4 is the Least
Significant Digit. Significant Digit.

- Take Note: Decimal number bases cannot be used for internal data representation in
computers because it is difficult to design electronic circuits for 10 different states.

Binary Number Base


- This is the most commonly used number base in computers
- The base of the binary number base is 2
- There are only two unique symbols in the binary number base
- The symbols are 0 and 1
- The maximum or largest value of the binary digit is 1
- Binary digits are commonly known as bits
- Electronic circuits are designed based on the binary base because it has only two symbols;
0 and 1 corresponding to ON and OFF.
Counting numbers in the binary base
- The table and number line below shows how the numbers are counted:

Table 1.2: Sequence of Binary Number Base

Iteration 1 0 1
Iteration 2 10 11
Iteration 3 100 101 111
Iteration 4 1000 1001 1011 1111

Figure 1.2: Binary Number Base number line

| | | | | | | | | |
-11 -10 -1 0 1 10 11 100 101 111

- Any number in the binary base can be represented by using the two symbols (0 and 1)
arranged in various positions.
- The binary base is a positional value base in which each position is expressed in the
powers of 2. See Example 1.3
- If the fractional part exists, their positional values are expressed in the negative powers
of 2. See Example 1.4

Converting binary numbers to decimal


- A binary number is converted to decimal by multiplying each bit by its positional value
(expressed in the powers of 2) and taking the sum these products.

Example 1.3 Example 1.4


The decimal equivalent of the binary number The decimal equivalent of the binary number
10112 can be written as: 110.112 can be written as:

101102 = 1 x 24 + 0 x 23 + 1 x 22 + 1 x 21+ 0 x 20 110.112 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2


= 16 + 0 + 4 + 2 + 0 = 4 + 2 + 0 + 0.5 + 0.25
= 2210 = 6.7510

In the number 10110, 1 at the extreme left is the In the number 110.112, the positional value of
Most Significant Bit (MSB) and 0 at the the 1 at the extreme right is -2 (from 2-2).
extreme right is the Least Significant Bit (LSB).

Converting decimal numbers to binary

- There are several ways of converting decimal numbers to binary.


- A simple technique involves repeated division by 2. The steps are as follows:
 Divide the number by 2 giving the quotient and the remainder.
 Repeat previous step with the new quotient until a zero quotient is obtained.
 The answer is obtained by reading the remainder column from the bottom to the top.

Example 1.5 Example 1.6

The binary equivalent of the decimal number The binary equivalent of the decimal number
53 can be written as: 72 can be written as:

Base Digit Remainder Base Digit Remainder


2 53 1 Top 2 72 0 Top
2 26 0 2 36 0
2 13 1 2 18 0
2 6 0 2 9 1
2 3 1 2 4 0
2 1 1 Bottom 2 2 0
2 1 1 Bottom
Therefore 5310 = 1101012

Therefore: 7210 = 10010002

Converting a real number to binary

- To convert a real number such as 41.6875 into binary, you first separate the integer part
(41) and the fractional part (0.6875)
- You then convert the integer part on its own and the fractional part on its own
- The steps to convert the fractional part are as follows:
 Multiply the number by 2
 Multiply the answer again by 2
 Repeat multiplying the answers by 2 until the final answer is 1.
 The final solution is obtained by reading the integer part of the answers from the top
to the bottom.
Example 1.7

The binary equivalent of the integer part 41 can The binary equivalent of the fractional part
be written as: 0.6875 can be written as:

Base Digit Remainder Integer Part Fraction


2 41 1 Top 0 . 6875
Top
2 20 0 x2
2 10 0 1 . 3750
2 5 1 x2
2 2 0 0 . 7500
2 1 1 Bottom x2
1 . 5000
Therefore 4110 = 1010012 x2
Bottom 1 . 0000
e
Therefore: 0.687510 = 0.10112

The final answer of 41.687510 = 1010012 + 0.10112


= 101001.10112

Octal Number Base


- The base of the octal number base is 8
- There are eight unique symbols in the octal number base
- The symbols are 0, 1, 2, 3, 4, 5, 6 and 7
- The maximum or largest value of the octal digit is 7

Counting numbers in the octal base

- The table and number line below shows how the numbers are counted:

Table 1.3: Sequence of Octal Number Base

Iteration 1 0 1 2 3 4 5 6 7
Iteration 2 10 11 12 13 14 15 16 17
Iteration 3 20 21 22 23 24 25 26 27
Iteration 4 30 31 32 33 34 35 36 37
Figure 1.3: Octal Number Base number line

| | | | | | | | | | | | | | | | | | | |

-3 -2 -1 0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20

- Any number in the octal base can be represented by using the eight symbols arranged in
various positions.
- The octal base is a positional value base in which each position is expressed in the powers
of 8. See Example 1.8
- If the fractional part exists, their positional values are expressed in the negative powers
of 8. See Example 1.9

Converting octal bases to decimal

- An octal number is converted to decimal by multiplying each bit by its positional value
(expressed in the powers of 8) and taking the sum these products.

Example 1.8 Example 1.9


The octal number 57268 can be written as: The octal number 135.248 can be written as:

59268 135.248
=5x8 +9x8 +2x8 +6x8
3 2 1 0 = 1 x 82 + 3 x 81 + 5 x 80 + 2 x 8-1 + 4 x 8-2
= 2560 + 576 + 16 + 6 = 64 + 24 + 5 + 0.25 + 0.0625
= 3158 = 93.3125

Therefore 59268 = 315810 Therefore 135.248 = 93.312510

Converting decimal bases to octal

- The decimal number is converted to octal by repeatedly dividing the number by 8. The
steps are as follows:
 Divide the number by 8 giving the quotient and the remainder.
 Repeat previous step with the new quotient until a zero quotient is obtained.
 The answer is obtained by reading the remainder column from the bottom to the top.
Example 1.10 Example 1.11

The octal equivalent of the decimal The octal equivalent of the decimal number
number 53 can be written as 72 can be written as

Base Digit Remainder Base Digit Remainder


8 53 5 8 72 0
8 6 6 8 9 1
8 1 1

Therefore: 7210 = 1108


Therefore 5310 = 658

Converting octal number to binary

- The octal number is converted to binary by individually converting each octal digit to its
three bit equivalent and then combining the results to form the binary representation of
the octal number.

Example 1.12 Example 1.13


The binary equivalent of the octal number The binary equivalent of the octal number
538 can be written as: 7248 can be written as:

Octal digit 5 3 Octal digit 7 2 4


Binary 101 011 Binary 111 010 100

Therefore 538 = 101 0112 Therefore: 7248 = 111 010 1002

Converting binary number to octal

- The binary number is converted to octal by grouping the bits of the binary number are
grouped into groups of three bits starting from binary point.
- Then each group is converted into its octal equivalent. If a group does not have three bits,
then add one or two zeros to make it a group of three.
Example 1.14
The octal equivalent of the binary number 1101001.10112 can be written as:

Binary group 001 101 001 . 101 100


Octal digit 1 5 1 . 5 4

Therefore 1101001.10112 = 151.548

Example 1.15
The octal equivalent of the binary number 100112 can be written as

Binary group 010 011


Octal 2 3

Therefore: 100112 = 238

Hexadecimal Number Base


- The base of the hexadecimal number base is 16
- There are sixteen unique symbols in the hexadecimal number base
- The symbols are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F
- A, B, C, D, E and F represent the decimal equivalent of 10, 11, 12, 13, 14 and 15
respectively.
- The maximum or largest value of digit is F
- Hexadecimal stores more values than all the number bases so it is used for various
applications which include:
 Specifying memory addresses in the computer
 Colour referencing in computer programs

Counting numbers in the hexadecimal base


- The table and number line below shows how the numbers are counted:
Table 1.4: Sequence of Hexadecimal Number Base

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

Iteration 2 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F

Iteration 3 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F

Iteration 4 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
Figure 1.4: Hexadecimal Number Base number line
| | | | | | | | | | | | | | | | | | | | | |

-3 -2 -1 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12

- Any number in the hexadecimal base can be represented by using the sixteen symbols
arranged in various positions.
- Each position is expressed in the powers of 16. See Example 1.16
- If the fractional part exists, their positional values are expressed in the negative powers
of 16. See Example 1.17

Converting hexadecimal bases to decimal


- A hexadecimal number is converted to decimal by multiplying each bit by its positional
value (expressed in the powers of 16) and taking the sum these products.

Example 1.16 Example 1.17


The hexadecimal number 5A2C16 can The hexadecimal number 135.C416 can be
be written as: written as
= 5 x 163 + A x 162 + 2 x 161 + C x 160 = 1 x 162 + 3 x 161 + 5 x 160 + C x 16-1 + 4 x 16-2
= 5 x 163 + 10 x 162 + 2 x 161 + 12 x 160 = 1 x 162 + 3 x 161 + 5 x 160 + 12 x 16-1 + 4 x 16-2
= 20480 + 2560 + 32 + 12 = 256 + 48 + 5 + 0.0625 + 0.00390625
= 309.06640625
= 23084
Therefore 135.C416 = 309.0664062510
Therefore 5A2C16 = 2308410

Converting decimal bases to hexadecimal


- The decimal number is converted to hexadecimal by repeatedly dividing the number by
16. The steps are as follows:
 Divide the number by 16 giving the quotient and the remainder.
 Repeat previous step with the new quotient until a zero quotient is obtained.
 The answer is obtained by reading the remainder column from the bottom to the top.

Example 1.18 Example 1.19

The hexadecimal equivalent of the decimal The hexadecimal equivalent of the decimal
number 53 can be written as number 72 can be written as

Base Digit Remainder Base Digit Remainder


16 53 5 16 72 8
16 6 3 16 4 4

Therefore 5310 = 3516 Therefore: 7210 = 4816


Converting hexadecimal number to binary
- The hexadecimal number is converted to binary by individually converting each
hexadecimal digit to its four bit equivalent and then combining the results to form the
binary representation of the hexadecimal number.

Example 1.20 Example 1.21

The binary equivalent of the hexadecimal The binary equivalent of the hexadecimal
number 5316 can be written as number 72A16 can be written as

Hex digit 5 3 Octal digit 7 2 A(10)


Binary 0101 0011 Binary 0111 0010 1010

Therefore 5316 = 101 0112 Therefore: 72416 = 0111 0010 10102

Converting binary number to hexadecimal


- The binary number is converted to hexadecimal by grouping the bits of the binary
number are grouped into groups of four bits starting from binary point.
- Then each group is converted into its binary equivalent. If a group does not have four
bits, then add zeros to make it a group of four.

Example 1.22

The hexadecimal equivalent of the binary number 1101001.10112 can be written as

Binary group 0110 1001 . 1011


Hex digit 6 9 . B

Therefore 1101001.10112 = 69.B16

Example 1.23

The hexadecimal equivalent of the binary number 100112 can be written as

Binary group 0001 0011


Hex 1 3

Therefore: 100112 = 1316


REPRESENTING NEGATIVE NUMBERS
- There are many ways of representing negative numbers
- However we will look at two’s complement as a way of representing negative numbers

a. Two’s Complement
- To represent a negative number as two’s complement you use the following steps:
 Convert the number into binary
 Invert every digit in the binary number i.e. a 1 becomes a 0 and a 0 becomes a 1
 After inverting the digits add 1 to the result.

Example 1.24 Example 1.25

The two’s complement of the decimal The two’s complement of the decimal
number -53 can be written as: number -70.625 can be written as:

Step 1: 5310 = 001101012 Step 1: 70.62510 = 01000110.1012 (see Example 1.4)

Step 2: 001101012  110010102 Step 2: 01000110.1012  10111001.0102

Step 3: 110010102 Step 3: 10111001.0102


+1 +1
-------------- ------------------
110010112 10111010.0112
Therefore: -5310 = 110010112 Therefore: -70.62510 = 10111010.0112
Take note the answer is expressed as 8bits Take note the answer is expressed as 8bits

- The leftmost digit in a 2’s is the sign bit therefore a number in two’s complement starts
with a 1

Subtraction using 2’s compliment


- When you want to subtract two binary numbers using 2’s complement, use the
following steps:
 Find the 2’s compliment of the subtrahend
 Add the 2’s compliment of the subtrahend with the minuend.
 If there is a carry over, ignore it, the final result would be positive (See Example 1.26)
 If there is no carry over, the final answer will be a negative number in 2’s
compliment (See Example 1.27)
- Take note: Before making calculations, ensure that the number of bits in the subtrahend
is equal to that of the minuend.
Example 1.26 Example 1.27

11012 – 01112 can be solved as: 10100.012 – 11011.102 can be solved as:

Step 1: - 01112  10012 (in 2’s compliment) Step 1: - 11011.102  00100.102

Step 2: 11012 Step 2: 10100.012


+ 10012 + 00100.102
-------------- --------------
101102 11000.112
Step 3: Therefore: 11012 – 01112 = 01102 Step 3: Therefore: 10100.012 – 11011.102 =
Take note, we ignore the one at the extreme 11000.112
right. It’s an overflow digit since the answer is Take note that since there is no carry over the
expressed as 4bits result is negative. In its ordinary form, the
answer would be - 00111.012

DISCLAIMER NOTICE:
This study guide may contain inaccuracies or errors. I provide no guarantee
regarding the accuracy, timeliness or completeness of information contained
herein. This guide is also not intended to replace learning material recommended
by Zimsec but instead it is there to complement the leaner’s study experience.
If you discover any errors do not hesitate to get in touch with me.

You might also like