You are on page 1of 10

Number System

PART I: Number Systems


Objectives:
At the end of the lesson student should be able to:
- Describe denary, binary, hexadecimal and octal number systems
- Convert a number from a base to another
- Perform the operations(addition, substation, multiplication, division) on binary numbers

Introduction
Since the early days of human civilization, people have been using their fingers, sticks and other things for counting.
As daily activities became more complex, the numbers became more important in trade, time, distance, and in all other
spheres of human life. It became apparent that we needed more than our fingers and toes to keep track of the number in
our daily routine. In 3400 BC, the ancient Egyptians started using special symbols for writing the numbers. This was a
major advancement, because it reduced the number of symbols required. However, it was difficult to represent large or
small numbers by using such a graphical approach. Today there are many number systems like decimal, hexadecimal
and binary that helps us to come over those limitations.

I. Definitions
A number system of base (also called radix) r is a system, which has r distinct symbols for r digits. A string of these
symbolic digits represents a number.The base or radix of the decimal system is 10. This implies that there are 10
symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
Examples:
✓ (7592)10 is of base 10 number system.
✓ (214)8 is of base 8 number system.
✓ (123)16 is of base 16 number system
Coding is the conversion from decimal base (base 10) to any non-decimal base b ( 𝑏 ≠ 10).
To decode is to convert from a non-decimal base b (𝑏 ≠ 10) to the decimal base (base 10).
Encoding is the conversion from a non-decimal base to a non-decimal base. Some special cases would be
distinguished.

II. Decimal, binary, octal, hexadecimal number systems


2.1. Decimal
Decimal number system has ten digits represented by 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Any decimal number can be
represented as a string of these digits. The base or radix of this system is 10. Example: The number 234 can be
represented in quantity as: 2×102+3×101+4×100.

Page 1
By DEMANOU YMELE ROMEO
Number System
Digit 2 9 8
Positional value 102 101 100
Representing 2×100 9×10 8×1
value
Therefore, 2×100 + 9×10 +8×1 = 29810

3. Binary numbers
The basis of all digital data is binary representation. Binary - means ‘two’. A digit in base 2 ranges from 0 to 1. A digit
in base 2 is also called a ‘bit’. A binary number is represented as a string of bits. The base of binary number system is
2.
e.g.: (11001101)2 is a binary number.

4. Hexadecimal numbers
The hexadecimal system has 16 digits, which are represented as 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F. The hexadecimal
(base 16) number system is used by the computer to communicate with programmers. Example: (2A)16, DFA1 represent
hexadecimal numbers.

5. Octal numbers
An octal system has eight digit represented as 0, 1, 2, 3, 4, 5, 6, 7. Any Octal number can be represented as a string of
these digits. The base of this system is 8.
Example: (177)8 is an octal number but (199)8 is not because the digit 9 does not exist in the octal number system.
Decimal Binary Octal Hexadecimal
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Page 2
By DEMANOU YMELE ROMEO
Number System
III. Operations on binary numbers
3.1. Binary addition
The rules for binary addition are:
0 + 0 = 0, carry = 0
1 + 0 = 1, carry = 0
0 + 1 = 1, carry = 0
1 + 1 = 0, carry = 1
Decimal Binary
34 101011
+ 17 +000001
…….. ………….
15 101100
7 + 4 = 1, with carry 1 + 1 = 0, carry of 1
out of 1 to next column 1 (carry) + 1 + 0 = 0, carry of 1
1 (carry) + 3 + 1 = 5 1 (carry) + 0 + 0 = 1, no carry
answer = 51 1+0=1
0+0=0
1+0=1
answer = 1 0 1 1 0 02

3.2. Binary subtraction


The rules for binary subtraction are:
0 - 0 = 0, borrow = 0
1 - 0 = 1, borrow = 0
0 - 1 = 1, borrow = 1
1 - 1 = 0, borrow = 0
Decimal Binary
900 100
- 001 - 001
…….. ………….
899 011
0 - 1 = 9, with borrow of 1 0 - 1, with borrow of 1
0 - 1 (borrow) - 0 = 9, with 0-1(borrow)-0=1, with borrow of 1
borrow of 1 1 - 1(borrow) - 0 = 0
9 - 1 (borrow) – 0 = 8 answer = 0 1 12
answer = 899

V
3.3. Binary multiplication
The multiplication process for binary numbers is similar to that for decimal numbers. Partial products are formed,
with each product shifted one place to the left. This is illustrated below.

Page 3
By DEMANOU YMELE ROMEO
Number System

Rules of binary multiplication


Example,
a) 111 x 101

b) 101001 × 110 = 11110110


101001 = (41)10
× 110 = (6)10
000000
101001
101001

3.4. Binary division


Binary division follows a similar process to that of decimal division. Example:
- Perform the following decimal division: 4525:20
- Then compute:
• 100:10
• 11011:101
• 10110:11

IV. Converting from one number system to another


a. Conversion from Any Base to Decimal (decoding)
Converting from ANY base to decimal is done by multiplying each digit by its weight and summing. Ex:
Binary to Decimal
112 = 1×21 + 1×20 = 310
1011.112 = 1×23 + 0×22 + 1×21 + 1×20 + 1×2-1 + 1×2-2
= 8 + 0 + 2 + 1 + 0.5 + 0.25
= 11.7510

Page 4
By DEMANOU YMELE ROMEO
Number System
Hex to Decimal
A2Fh = 10 ×162 + 2 ×161 + 15 ×160
= 10 × 256 + 2 × 16 + 15 × 1
= 2560 + 32 + 15 = 2607

Exercise 1:
Convert the numbers 10010112, 2300158, 11101.0112 D25F3A16, F216 and 23.48 into denary numbers.

Conversion of non-decimal fractions to decimal fraction


The negative exponents are used to denote the negative powers of base b. The exponential expressions of each
fractional placeholder are b-1, b-2, and in this way the exponent notation proceeds. The steps involved in the conversion
process are the following:
1. Write the weight value of each bit of the non-decimal fractional number.
2. Multiply the weighted position with the respective bit of the non-decimal fractional number.
3. Add all the weighted values to get the decimal number.

Examples:
a) Determine the decimal equivalent of (0.01101)2.

(1/4 + 1/18 + 1/32 = 040625)


Thus, (0.01101)2 is (0.40625)10.

b) Determine the decimal equivalent of (237.04)8.

Sum of weight of all bits = 128 + 24 + 7 + 0 + 0.0625 = 159.0625


Thus, (237.04)8 is (159.0625)10.

c) Determine the decimal equivalent of (45C.8BE3)16.

Sum of weight of all bits = 1024 + 80 + 12 +0.5 + .0429687 + .0034179 + .0000457= 1116.5464323

Page 5
By DEMANOU YMELE ROMEO
Number System
Thus, the decimal equivalent of (45C.8BE3)16 is (1116.5464323)10.

b. Conversion from Decimal To ANY Base (of radix R - coding)


Divide Number N by radix R until quotient is 0. The remainder at each step is a digit in base R, from Least Significant
digit to the Most significant digit.
Ex: Convert 53 to binary
53/2 = 26, rem = 1 (least significant digit)
26/2 = 13, rem = 0
13/2 = 6 , rem = 1
6 /2 = 3, rem = 0
3/2 = 1, rem = 1
1/2 = 0, rem = 1(most significant digit)
5310 = 1101012
= 1×25 + 1×24 + 0×23 + 1×22 + 0×21 + 1×20
= 32 + 16 + 0 + 4 + 0 + 1 = 53
To convert a denary number to another number system with base b, we can follow the steps below:
1. Divide the denary number by b repetitively until the quotient is smaller than b.
2. Obtain the answer by writing up from the quotient to the remainders in reverse order.

Most significant digit= LEFTMOST digit


Least significant digit= RIGHTMOST digit.
Ex: Convert 53 to Hex
53/16 = 3, rem = 5
3 /16 = 0 , rem = 3
5310 = 3516
= 3 × 161 + 5 × 160
= 48 + 5 = 53

Page 6
By DEMANOU YMELE ROMEO
Number System
Exercise
convert 56210, 4310 to binary

Conversion of decimal fraction


1. Multiply the decimal fraction by the base b.
2. If a whole number is generated, place that integer in that position, if not then place 0.
3. Remove the whole number and continue steps 1 and 2 with the fraction value until it becomes 0.
4. Finally, when no more multiplication can occur, write down the remainders in the downward direction (as shown by
the arrow mark).

Examples:
- Determine the binary equivalent of (0.375)10.
0.375 x 2 = 0.75 0
0.75 x 2 = 1.5 1
0.5 x 2 = 1.0 1
Finally, (0.375)10 = (0.011)2

- Determine hexadecimal conversion of (671.175)10


(671)10 = (29F)16. Now let convert (0.175)10 in base 16
0.175 x 16 = 2.8 2
0.8 x 16 = 12.8 C
0.8 x 16 = 12.8 C
....
Finally, (671.175)10 = (29F.2CCC...)16

c. Hex (base 16) to Binary Conversion


Each Hex digit represents 4 bits. To convert a Hex number to Binary, simply convert each Hex digit to its four bit value.
Hex Digits to binary:
$ 0 = % 0000 $ 6 = % 0110 $ B = % 1011
$ 1 = % 0001 $ 7 = % 0111 $ C = % 1100
$ 2 = % 0010 $ 8 = % 1000 $ D = % 1101
$ 3 = % 0011 $ 9 = % 1001 $ E = % 1110
$ 4 = % 0100 $ A = % 1010 $ F = % 1111
$ 5 = % 0101
Ex: A2F16 = 1010 0010 11112
34516 = 0011 0100 01012

Page 7
By DEMANOU YMELE ROMEO
Number System
- Determine the binary equivalent of (5AF)16.

(5AF)16 = (010110101111)2

- Determine the binary equivalent of (2B.6C)16

(2B.6C)16 = (00101011.01101100)2.

d. Binary to Hex
Binary to Hex is just the opposite; create groups of 4 bits starting with least significant bits. If last group does not have
4 bits, then pad with zeros.
0100012 = 0101 00012 = 5116
- Determine the hexadecimal equivalent of (101011110011011001)2

(101011110011011001)2 = (2BCD9)16.
- Determine the hexadecimal equivalent of (1100001.101011110011)2.

(1100001.101011110011)2 = (61.AF3)16.

Exercise: Convert 1110012, 100001102 and 111110 to hex


e. Binary to octal
For converting binary to octal the binary number is divided into groups of three, which are then combined by place value
to generate equivalent octal. For example
1 101 011
001 101 011
(We have added 0 to complete the grouping)
for each three binary digit, we calculate the equivalent octal value as follow:
0 1 1 = 0×22 +1×21 + 1×20 = 0 + 2 + 1 =3
1 0 1 = l×4+0×2+1×1=5
0 0 1 = 0×4+0×2+ 1×1 =1
Then the number is 1538

The binary representation of octal digits is listed below:

Page 8
By DEMANOU YMELE ROMEO
Number System

f. Conversion of Octal to Hexadecimal


This conversion involves the following steps:
1. Convert each octal digit to three-bit binary form.
2. Combine all the three-bit binary numbers.
3. Divide the binary numbers into the four-bit binary form by starting the first number from the right bit to the first
number from the left bit.
4. Finally, convert these four-bit blocks into their respective hexadecimal symbols.
Examples:
a) Determine the hexadecimal equivalent of (2327)8.

Combining the three-bit binary blocks, we have 010011010111.


Dividing the group of binary numbers into the four-bit binary blocks and by converting these blocks into their respective
hexadecimal symbols, we have:

(2327)8 = (4D7)16.

b) Determine the hexadecimal equivalent of (31.57)8.

Combining the three-bit binary blocks, we have 011001.101111.


Dividing the group of binary numbers into the four-bit binary blocks and by converting these blocks into their respective
hexadecimal symbols, we have:

Thus, (31.57)8 = (19.BC)16.

g. Conversion of Hexadecimal to Octal

Page 9
By DEMANOU YMELE ROMEO
Number System
This conversion follows the same steps of octal to hexadecimal conversion except that each hexadecimal digit is
converted into a four-bit binary form and then after grouping of all the four bit binary blocks, it is converted into the
three-bit binary form. Finally, these three-bit binary forms are converted into octal symbols.
Examples:
a) Determine the octal equivalent of (5DE247)16.

Combining all the four-bit binary blocks, we have 010111011110001001000111.

Dividing the group of binary numbers into the three-bit binary blocks and by converting these blocks into their respective
octal symbols, we have:

Thus, the octal equivalent of (5DE247)16 is (27361107)8.


b) Determine the octal equivalent of (7B.64D)16.

Combining all the four-bit binary blocks, we have 01111011.011001001101.


Dividing the group of binary numbers into the three-bit binary blocks and by converting these blocks into their respective
octal symbols, we have:

Thus, the hexadecimal equivalent of (7B.64D)16 is (173.3115)8

Exercise 3:
1. Consider the following numbers:
123 954 A01 001 1111 0002 0011 547 25455 25A DFA1 258
1.a. Which numbers are binary?
1.b. Identify those which are decimal but not octal
1.c. Convert numbers found in (1.b) into binary.
2. Compute:
a) 100012 + 11 b) 11101102 + 1112
c) 111002 - 100012 d) 110111002 - 11112
3. Convert 10000111010012 to the following bases: 10, 8 and 16

Page 10
By DEMANOU YMELE ROMEO

You might also like