Logic Circuits and Switching Theory: Number System Conversion

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

ECE 322

LOGIC CIRCUITS AND


SWITCHING THEORY

Module 1

NUMBER SYSTEM :

CONVERSION
Objectives

At the end of the lesson, the student should be able to :

 Identify the different number system as they relate


to computers
 Identify the unit, number, base/radix, positional
notation, least significant digit and most
significant digit
 Convert values from any number system to each
other and back to other systems
Number base
What is a number base?
A number base is a specific collection of
symbols on which a number system can be built.

 The number base familiar to us is base 10, in


which the decimal number system is built.
 There are ten symbols used in the decimal system.
Symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Number base

Number
Base Symbol
System

Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Binary 2 0, 1

Octal 8 0, 1, 2, 3, 4, 5, 6, 7

Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Place value

What is the concept of place value?


Place value means that the value of a digit in a
number depends not only on its own natural value but
also on its location in the number.

 It is termed as positional notation.


 Place value tells us that the two 5s in the number
1575 have different values, that is, 500 and 5,
respectively.
Decimal Number System

 The word “decimal” comes from the Latin word


decem, meaning ten.
 Thus, the number base of the decimal number
system is base 10.
 Since it is in base 10, ten symbol are used in
the decimal number system.
{0,1,2,3,4,5,6,7,8,9}
 This means that only the digits in the above set can
be used for each position in every place value in a
given decimal number.
Decimal Number System (cont…)
1 8 0

 Note that the highlighted place value can be filled by the


digits in the set {0,1,2,3,4,5,6,7,8,9}.
 Thus, it can be increased by 1 until it reaches
1 8 9

 At this point, the symbols that can be used to fill the


highlighted position has been exhausted. Increasing it
further causes a shift in place value, and resets the initial
place value to zero. Thus,
1 9 0
Decimal Number System (cont…)

Example: 4292
Using place values, the number 4292
is understood to mean,
4000 + 200 + 90 + 2 = 4292
This can also be expressed as
(4x1000) + (2x100) + (9x10) +
(2x1) = 4292

Hence, the decimal number system is said to be


in base 10.
Decimal Number System (cont…)

Example: 4292
 Note that each digit is multiplied by powers of 10,
so that the above is equal to –
(4x103) + (2x102) + (9x101) + (2x100) = 4292
(4x1000) + (2x100) + (9x10) + (2x1) = 4292
4000 + 200 + 90 + 2 = 4292
 Note that the rightmost exponent starts from zero
and increases by 1 as the place value increases.
 Noticed that the most significant value or the
leftmost value has an exponent equal to the number
of digits minus one.
Binary Number System

 The word “binary” comes from the Latin word bis,


meaning double.
 Thus, the number base of the binary number system
is base 2.
 Since it is in base 2, two symbol are used in
the binary number system.
{0,1}
 This means that only the digits in the above set can
be used for each position in every place value in a
given binary number.
Binary Number System (cont…)
1 0 0

 Note that the highlighted place value can be filled by the


digits in the set {0,1}.
 Thus, it can be increased by 1 until it reaches
1 0 1

 At this point, the symbols that can be used to fill the


highlighted position has been exhausted. Increasing it
further causes a shift in place value, and resets the initial
place value to zero. Thus,
1 1 0
Binary Number System (cont…)

 To avoid confusion, one should write a binary number


with base 2 as its subscript whenever necessary.
 Thus, the binary number 110010 should be written as
1100102
 It should be read as “one-one-zero-zero-one-zero base
two” and NOT “one- hundred ten thousand ten” since
each phrase denotes an entirely different number.
Binary Number System (cont…)
Example: 1100102
 We know that the decimal number 4292
can be expressed as power of 10
(4x103) + (2x102) + (9x101) + (2x100) =
4292
 Using place values, the number 1100102 is
understood to mean, 1000002 + 100002 +
00002 + 0002 + 102 + 02 = 1100102
Binary Number System (cont…)
Example: 1100102
 Note that each digit is multiplied by powers of 2, so
that the above is equal to:
(1x25) + (1x24) + (0x23) + (0x22) + (1x21) + (0x20) =
Note that the rightmost exponent starts from zero and
increases by 1 as the place value increases.
Noticed that the most significant value or the leftmost
value has an exponent equal to the number of digits
minus one.
(1x32) + (1x16) + (0x8) + (0x4) + (1x2) + (0x1) =
32 + 16 + 0 + 0 + 2 + 0 = 5010
Octal Number System

 The word “octal” comes from the Greek word oktõ,


meaning eight.
 Thus, the number base of the octal number system is
base 8.
 Since it is in base 8, eight symbols are used in the
octal number system.
 {0,1,2,3,4,5,6,7}
 This means that only the digits in the above set can
be used for each position in every place value in a
given octal number.
Octal Number System (cont…)
2 6 0

 Note that the highlighted place value can be filled by the


digits in the set {0,1,2,3,4,5,6,7}.
 Thus, it can be increased by 1 until it reaches
2 6 7

 At this point, the symbols that can be used to fill the


highlighted position has been exhausted. Increasing it
further causes a shift in place value, and resets the initial
place value to zero. Thus,
2 7 0
Octal Number System (cont…)

 To avoid confusion, one should write an octal number


with base 8 as its subscript whenever necessary.
 Thus, the octal number 5275 should be written as 52758
 It should be read as “five-two-seven-five-base eight”
and NOT “five thousand two hundred seventy five”
since each phrase denotes an entirely different number.
Octal Number System (cont…)
Example: 625438
• We know that the decimal number 5254 can be
expressed as powers of 10
(5x103) + (2x102) + (5x101) + (4x100) = 525410
• Using place values, the number 625438 is understood
to mean,
600008 +20008 + 5008 + 408 + 38 = 625438
• In the same manner, the octal number 625438 can be
expressed as powers of 8 :
(6x84) + (2x83) + (5x82) + (4x81) + (3x80) =
Octal Number System (cont…)
Example: 625438

 Note that the rightmost exponent starts from zero and


increases by 1 as the place value increases.
 Noticed that the most significant value or the leftmost
value has an exponent equal to the number of digits
minus one.
(6x84) + (2x83) + (5x82) + (4x81) + (3x80) =
(6x`4096)+(2x512)+(5x64)+(4x8)+(3x1) =
24576 + 1024 + 320 + 32 + 3 = 25955
 Hence, the octal number system is said to be in base 8.
Hexadecimal Number System
• The word “hexadecimal” is a combination of
the Greek word hex, meaning six and the Latin
word decem, meaning ten.
• Thus, the number base of the hexadecimal number
system is base 16.
• Since it is in base 16, sixteen symbols are used
in the hexadecimal number system.
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
• This means that only the digits in the above set can be
used for each position in every place value in a given
hexadecimal number.
Hexadecimal Number System (cont…)
2 B 0

• Note that the highlighted place value can be filled


by the digits in the set
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}.
• Thus, it can be increased by 1 until it reaches -
2 B F

• At this point, the symbols that can be used to fill the


highlighted position has been exhausted.
Increasing it further causes a shift in place value, and
resets the initial place value to zero.
Thus : 2 C 0
Hexadecimal Number System (cont…)

• To avoid confusion, one should write a hexadecimal


number with base 16 as its subscript whenever
necessary.
• Thus, the hexadecimal number F4C2 should be
written as : F4C216
• It should be read as “f-four-c-two base sixteen”.
• The hexadecimal number 1973 should be written
as : 1973 16
• It should be read as “one-nine-seven-three base
sixteen”.
Hexadecimal Number System (cont…)
Example: F4C216
• We know that the decimal number 3474 can be
expressed as powers of 10 –
(3x103) + (4x102) + (7x101) + (4x100) = 347410
• Using place values, the number F4C216 is understood
to mean,
F00016 +40016 + C016 + 216 = F4C216
• In the same manner, the hexadecimal number F4C216
can be expressed as powers of 16 –
(Fx163) + (4x162) + (Cx161) + (2x160) = ?
Hexadecimal Number System (cont…)
Example: F4C216
 Note that the rightmost exponent starts from zero
and increases by 1 as the place value increases.
 Noticed that the most significant value or the
leftmost value has an exponent equal to the
number of digits minus one.
(Fx163) + (4x162) + (Cx161) + (2x160) = ?
(15x163) + (4x162) + (12x161) + (2x160) = ?
(15x4096) + (4x256) + (12x16) + (2x1) = ?
61440 + 1024 + 192 + 2 = 62658
 Hence, the hexadecimal number system is said to
be in base 16.
Hexadecimal Number System (cont…)
Example:
F4C216
2 x 16 0 = 2x1 = 2
12 x 16 1 = 12 x 16 = 192
4 x 16 2 = 4 x 256 = 1024
15 x 16 3 = 15 x 4096 = 61440
6265810
Comparative Values : Bases 10,2,8,16
(decimal-binary-octal-hexadecimal)
Base 10 Base 2 Base 8 Base 16
Decimal Binary Octal Hexadecimal
0 0000 0 0
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
Comparative Values : Bases 10,2,8,16
(decimal-binary-octal-hexadecimal)
Base 10 Base 2 Base 8 Base 16
Decimal Binary Octal Hexadecimal
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
Binary to Decimal / Decimal to Binary
Binary to Decimal
To check: dec to bin
Example:
1100102 DIV Q R
50/2 = 25 0
0x20 = 0x1 = 0
25/2 = 12 1
1x21 = 1x2 = 2 12/2= 6 0
0x22 = 0x4 = 0 6/2 = 3 0
0x23 = 0x8 = 0 3/2 = 1 1
= 16 1/2 = 0 1
1x24 = 1x16
1x25 = 1x32 = 32
= 1100102
50
NOTE:
To convert any number system to decimal you need to use the expanded notation method.
While if you will convert decimal to any number system you will use the division remainder
method
Octal to Decimal / Decimal to Octal
Octal to Decimal
To check: dec to octal
Example:
DIV Q R
17458 997/8 = 124 5
5x80 = 5x1 = 5 124/8 = 15 4
4x81 = 4x8 = 32 15/8= 1 7
1/8 = 0 1
7x82 = 7x64 = 448
1x83 = 1x512 = 512
997 = 17458
NOTE:
 To convert any number system to decimal you need to use the expanded notation
method. Use the base from which number system is to be converted to decimal.
 While if you will convert decimal to any number system you will use the division
remainder technique. For integer division use the base into which number system will
be converted. Remember to use integer division since you are after the remainder.
Division operation will took place until quotient is equal to zero. The reversed order of
the remainder will form the equivalent number system.
Hexadecimal to Decimal /Decimal to Hexadecimal
Hexadecimal to Decimal
(Hexa to Dec) To check: dec to hexa
Example: DIV Q R
F4C216 62658/16 = 3916 2
3916/16 = 244 12 = C
2x160 = 2x1 = 2 244/16 = 15 4
Cx161 = 12x16 192 15/16 = 0 15 = F
=
4x162 = 4x256 = 1024
Fx163 = 15x4096 = 61440
= F4C216
62658
NOTE:
 To convert any number system to decimal you need to use the expanded notation
method. Use the base from which number system is to be converted to decimal.
 While if you will convert decimal to any number system you will use the division
remainder technique. For integer division use the base into which number system will
be converted. Remember to use integer division since you are after the remainder.
Division operation will took place until quotient is equal to zero. The reversed order of
the remainder will form the equivalent number system.
Octal to Binary / Binary to Octal
• Technique:
• If octal to binary. Convert each octal digit to a set of three
binary digits.
• If binary to octal. Convert each set of three binary digits to an
octal digit starting from the right going to the left, adding
leading zeroes if necessary.
• Use code : 4-2-1
• Convert 52638 to base 2/1010101100112 to base 8
Octal to Binary Binary to Octal
(Oct to Bin) 5263 8 101010110011
(Bin to Oct) 2
5 2 6 3 101 010 110 011
4-2-1 4-2- 4-2-1 4-2-1 4-2-1 4-2- 4-2-1 4-2-1
1 1
101 010 110 011 5 2 6 3
Answer: 1010101100112 Answer: 52638
Hexadecimal to Binary / Binary to Hexadecimal
• Technique:
• If hexa to binary. Convert each hexa digit to a set of four
binary digits.
• If binary to hexa. Convert each set of four binary digits to a
hexa digit starting from the right going to the left, adding
leading zeroes if necessary.
• Use code : 8-4-2-1
• Convert 6B716to base 2/110101101112 to base 16

Hexa to Binary 6B716 110101101112


Bin to Hexa
6 B =11 7 0110 1011 0111
8-4-2- 8-4-2-1 8-4-2- 8-4-2-1 8-4-2- 8-4-2-1
1 1 1
0110 1011 0111 6 11=B 7
Answer: 110101101112 Answer: 6B716
Case Study:
1635 = 2 = 8 = 16

DIV Q R
1635/2 817 1 DIV Q R DIV Q R
817/2 408 1 1635/8 204 3 1635/16 102 3
408 /2 204 0 204/8 25 4 102/16 6 6
204 /2 102 0 25 /8 3 1 6 /16 0 6
102 /2 51 0 3 /8 0 3
51/2 25 1
25/2 12 1 31438 66316
12/2 6 0
6/2 3 0
3/2 1 1
1/2 0 1
( Bin to Octal - use: code 4-2-1) ( Bin to Hexa - use: code 8-4-2-1)
110011000112 011/001/100/0112 0110/0110/00112

= 31438 = 66316
31438
66316
3x80 = 3x1 = 3 3x160 = 3x1 == 3
4x81 = 4x8 = 32 6x161 = 6x16 == 96
1x82 = 1x64 = 64 6x162 = 6x256 == 1536
3x83 = 3x512 = 1536 1635
1635
110011000112
1X20 = 1X1 = 1
1X21 = 1X2 = 2
0X22 = 0X4 = 0
0X23 = 0X8 = 0
0X24 = 0X16 = 0
1X25 = 1X32 = 32
1X26 = 1X64 = 64
0X27 = 0X128 = 0
0X28 = 0X256 = 0
1X29 = 1X512 = 512
1X210 = 1X1024 = 1024
1635
Summary
 A number base is a specific collection of symbols on which a
number system can be built.
 Place value means that the value of a digit in a number depends
not only on its own natural value but also on its location in the
number.
 Decimal number system has base 10. Since it is in base 10, ten
symbol are used in the decimal number system.{0,1,2,3,4,5,6,7,8,9}
 Binary number system has base 2. Since it is in base 2, two symbol
are used in the binary number system. {0,1}
 Octal number system has base 8. Since it is in base 8, eight
symbols are used in the octal number system. {0,1,2,3,4,5,6,7}
 Hexadecimal number system has base 16. Since it is in base 16,
sixteen symbols are used in the hexadecimal number system.
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}
Summary (continuation)
To convert any number system to decimal you need to
use the expanded notation method. Use the base from
which number system is to be converted to decimal.
While if you will convert decimal to any number system
you will use the division remainder technique. For
integer division use the base into which number system
will be converted. Remember to use integer division since
you are after the remainder. Division operation will took
place until quotient is equal to zero. The reversed order
of the remainder will form the equivalent number
system.
Summary (continuation)
If octal to binary. Convert each octal digit to a set of
three binary digits. While if binary to octal. Convert each
set of three binary digits to an octal digit starting from
the right going to the left, adding leading zeroes if
necessary. Use code : 4-2-1
If hexa to binary. Convert each hexa digit to a set of four
binary digits. While if binary to hexa. Convert each set
of four binary digits to a hexa digit starting from the
right going to the left, adding leading zeroes if necessary.
Use code : 8-4-2-1
Thanks for your time.

Do you have any question related to our


topic for today?

PM is the key

I will try to attend to your needs as soon as


possible.

You might also like