0% found this document useful (0 votes)
20 views51 pages

Lecture 2 - 3number System

Uploaded by

Defenders
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views51 pages

Lecture 2 - 3number System

Uploaded by

Defenders
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 51

Digital Logic Design

Data
Representation

Instructor: Muhammad Zeshan Qurashi

Department of Computing
Shifa Tameer-e-Millat University
(STMU). 1
Digital Data Representation
 A well known example of digital data is finite integer representation using Decimal Number
system
Decimal Number System
 It has Base 10
 A number base is the total number of digits that a system of counting uses to
higher numbers
 Decimal number system contains 10 numbers (0,1,2,…, 9) that are used to
represent any other number
 Decimal number system is a positional number system in which every
number greater
than 9 is represented as sum of products

2
Number System

3
Introduction

 Many number systems are in use in digital


technology. The most common are :
• Decimal (Base 10)
• Binary (Base 2)
• Octal (Base 8)
• Hexadecimal (Base 16)

• The decimal system is the number system


that we use everyday

4
Number System
 Decimal system uses 10 symbols
(digits)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Octal System uses eight symbols

0, 1, 2, 3, 4, 5, 6, 7
 Binary System uses only two

symbols
0 and 1
 Hexadecimal System uses sixteen

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

to represent any number, no matter how large or how 5


Decimal Number System

• Base (radix) = 10
– 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8,
9 } Position
• Digit 2 1 0 -1 -
– Integer & fraction 2
4 1 5 4 4
• Digit Weight
100 10 1 0.1 0.01
– Weight = (Base) Position

– Weight = (10) Position


• Magnitude
400 10 5 0.4 0.04
– Sum of “Digit x Weight”
d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2

• Formal Notation (415.44)10


6
Decimal System

 The decimal system is composed of 10 numerals or


symbols. These 10 symbols are 0,1,2,3,4,5,6,7,8,9;
using these symbols as digits of a number, we can
express any quantity.
 Example : 3501.51

3 5 0 1 . 5 1

digit
Most Least
Significant decimal Significant
Digit point Digit 7
Binary Number System

• Base (radix) = 2
– 2 digits { 0, 1 }, also called
“bits”
• Weights 4 2 1 1/2 1/4
– Weight = (Base) Position 1 0 1 0 1
– Weight = (2) Position
2 1 0 -1 -2
• Magnitude
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
– Sum of “Bit x Weight”
=(5.25)10
• Formal Notation
(101.01)2
• Groups of bits
– 4 bits = Nibble {1 0 1 1}
– 8 bits = Byte {1 1 0 0 0 1 0 1}
– 16 bits = {1 1 0 0 0 1 0 1 1 1 0 1 0 1 0
Word 0} 8
Binary System

 The binary system is composed of 2 numerals or


symbols 0 and 1; using these symbols as digits
of a number, we can express any quantity.
 Example : 1101.01

1 1 0 1 . 0 1

bit
Most Least
Significant binary Significant
Bit point Bit 9
Octal Number System
• Base (radix) = 8
– 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
• Weights 64 8 1 1/8 1/64

– Weight = (Base) Position 5 1 2 7 4


– Weight = (8) Position 2 1 0 -1 -
• Magnitude 2
5 *82+1 *81+2 *80+7 *8-1+4 *8-2
– Sum of “Digit x =(330.9375)10
Weight”
• Formal Notation (512.74)8

10
Hexadecimal Number System
• Base (radix) = 16
– 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E,
F}
256 16 1 1/16 1/256
• Weights
– Weight = (Base) Position

– Weight = (16) Position 1 E 5 7 A


• Magnitude 2 1 0
-1 -2
– Sum of “Digit x Weight”
1 *162+14 *161+5 *160+7 *16-1+10 *16-2

• Formal Notation =(485.4765625)10


(1E5.7A)16

11
Number Systems
• Decimal Numbers Decimal Binary Octal Hex
– 10 Digits 00 0000 00 0
• Binary Numbers 01 0001 01 1
02 0010 02 2
– 2 Digits/Bits
03 0011 03 3
• Octal Numbers 04 0100 04 4
– 8 Digits 05 0101 05 5
06 0110 06 6
• Hexadecimal
07 0111 07 7
Numbers 08 1000 10 8
– 16 Digits 09 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
12
Familia
r
Octal System Hexa decimal Decimal Binary
System
Base 4 number
(Base – 8 ns) Number Number Equivalent System
System (Base (Base-10) (Base-2) (Base -4)
– 16)
0 0 0 0 0
1 1 1 1 1
2 2 2 10 2
3 3 3 11 3
4 4 4 100 10
5 5 5 101 11
6 6 6 110 12
7 7 7 111 13
10 8 8 1000 20
11 9 9 1001 21
12 A 10 1010 22
13 B 11 1011 23
14 C 12 1100 30
15 D 13 1101 31
16 E 14 1110 32
17 F 15 1111 33
Number Systems

Number System Base Possible Digits

Decimal 10 0,1,2,…,9

Binary 2 0,1

Octal 8 0,1,2,…,8

Hexadecimal 16 0,1,..9,A,B,C,D,E,F

14
Bits, Bytes, Nibbles

 Bits (b) 10010110


most least
significant significant
bit bit

byte
 Bytes & Nibbles
🞑 Byte (B) = 8 bits 10010110
nibble
 Used everyday
🞑 Nibble (N)
 = Not
4 bits
commonly used CEBF9AD7
most least
significant significant
byte byte
15
KB, MB, GB …

 In computer, the basic unit is byte (B)


 And, we use KB, MB, GB many many many times
🞑 210 = 1024 = 1KB
(kilobyte)
🞑 220 = 1024 x 1024 = 1MB
(megabyte)
🞑 230 = 1024 x 1024 x 1024 = 1GB
(gigabyte)
 How about these?
🞑 240 = 1TB
🞑 250 = (terabyte)
🞑 260 = 1PB
🞑 270 = (petabyte)
🞑 … 1EB
(exabyte) 16
Decimal Number Quantity (positional
number)

 3501 (base-10)

1 X 100 = 1

0 X 101 = 0
5 X 102 = 500
3 X 103 = 3000

3000 + 500 + 0 + 1 = 3501

17
Binary-to-Decimal Conversion

 1101 (base-2)

1 X 20 = 1

0 X 21 = 0
1 X 22 = 4
1 X 23 = 8
8 + 4 + 0 + 1 = 13
11012= 1310
18
Digital Data Representation
Binary to Integer Number Conversion

100112 = (?)10
= (1 x 24) + (0 x 23) + (0 x 22) + (1 x 21)+ (1 x 20)
= (1 x 16) + (0 x 8) + (0 x 4) + (1 x 2) + (1 x 1)
= 16 + 0 + 0 + 2 + 1
= 1910

19
Octal-to-Decimal Conversion

 5217 (base-8)

7 X 80 = 7x1 = 7

1 X 81 = 1x8 = 8
2 X 82 = 2x64 = 128
5 X 83
= 5x512 = 2560
2560 + 128 + 8 + 7 = 2703
52178 = 270310 20
Hexadecimal-to-Decimal Conversion

 1AC (base-16) [ A = 10, B = 11, C = 12, D = 13, E = 14, F =


15 ]
F
15
15 X 160 =15x1 =
12 X 161 =12x16

192
10 X 162
=10x256 =
21
2560
Binary to Octal Conversion
• Each of 3 binary Octal Binary
represent
group an octal
bitsdigit
0 000
• Starting from fractional
point combine binary bits in group 1 001
of 3 2 010
Assume Zeros
Example:
3 011
( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111

Works both ways (Binary to Octal & Octal to Binary)


22
Binary to Hexadecimal
• 16 = 24 Hex Binary
• Each group of 4 bits 0 0000
1 0001
represents a hexadecimal digit 2 0010
3 0011
Assume Zeros 4 0100
Example: 5 0101
6 0110
( 1 0 1 1 0 . 0 1 )2 7 0111
8 1000
9 1001
A 1010
B 1011
(1 6 . 4 C 1100
)16 D 1101
E 1110
Works both ways (Binary to Hex & F 1111
Hex to Binary)
33 23
Decimal Number Quantity (fractional
number)
 .581 (base-10)

5 X 10-1 = 5x0.1 = 0.5

8 X 10-2 = 8x0.01 =
0.08
1 X 10 -3 =
1x0.001 = 0.001

0.5 + 0.08 + 0.001 = 0.581

24
Binary-to-Decimal
Conversion
 .101 (base-2)

1 X 2-1 = 1x0.5 =
0.5
0 X 2-2
= 0x0.25 = 0
1 X2 -3 =
1x0.125 = 0.125

0.5 + 0 + 0.125 = 0.625

0.1012 = 0.62510
25
Octal-to-Decimal
Conversion
 .25 (base-8)

2 X 8-1 = 2x0.125 =
0.25
5 X 8-2 =
5x0.015625 =
0.017825

0.25 + 0.017825 = 0.267825

0.258 = 0.26782510
26
Hexadecimal-to-Decimal
Conversion
 . F5 (base-16)

15 X16-1

= 15x0.0625 =
0.9375
5 X16-2

= 5x0.00390625
= 0.01953125

0.9375 + 0.01953125 = 0.95703125 27


Exercise 1
 Convert these binary system numbers to decimal
system numbers
a) 100101101
b)11100.1001
c)111111
d)100000.0111
 b)
1x24 + 1x23 + 1x22
+ 0x21 + 0x20 +
1x2-1 + 0x2-2 +
0x2-3 1+ 1x2-4

= 16 + 8 + 4+ 0
+ 0 + 0.5 + 0 + 28
Number Base Conversions : Practice Questions

• Convert the following from Binary to Decimal

–(101)2 , (11001)2 , (11100)2 , (11.010)2

• Convert the following from Octal to Decimal

–(17)8 , (76)8 , (236)8 , (35.25)8

• Convert the following from Hexadecimal to Decimal

–(7A)16 , (78F)16 , (109B)16 , (50.1C)16

29
Decimal-to-Binary Conversion(positional
number)
 250 25010 = 1 1 1 1 1 0 1 02
2 250 Remainder
2 125 Remainder
0
2 62 1
2 31 0
Remainder
2 15 Remainder 1
1
2 7
Remainder
Remainder 1
2 3
Remainder 1
1
30
Decimal to Binary Conversion

Example (Integer) : (13)10


Quotient Remainder Coefficient
13/ 2 = 6 1 a0 = 1
6/2= 3 0 a1 = 0
3/2= 1 1 a2 = 1
1/2= 0 1 a3 = 1

Answer: (13)10 = (a3 a2 a1 a0)2 =


(1101)2

Example (Fractional) : ( 0.125 )10

Answer: = (0.001)2
31
Decimal-to-Octal
Conversion
 250
8
8 31 Remainder 2
250 3 Remainder 7

25010 = 3728

32
Decimal-to-Hexadecimal
Conversion
 250
16 250
15 Remainder 10

25010 = 15 1016 ?
= FA16

33
Decimal-to-Binary Conversion(fractional
number)
 0 . 4375
0.4375 x 2 = 0.8750
0.8750 x 2 = 1.75
0.75 x2 = 1.5
0.5 x2 = 1.0

0.437510 = 0.01112

34
Decimal-to-Octal
Conversion
 0 . 4375
0.4375 x 8 = 3.5
0.5 x8 = 4.0

0.437510 = 0.348

35
Decimal-to-Hexadecimal
Conversion
 0 . 4375
0.4375 x 16 =
7.0

0.437510 = 0.716

36
Example :Decimal-to-Binary
Conversion(Estimation)
 0.782 110012  2-1 + 2-2 + 2-5
 0.5 + 0.25
0.782 x 2 = 1.564
+0.03125
0.564 x 2 = 1.128
 0.78125
0.128 x 2 = 0.256
0.256 x 2 = 0.512 11001000012
0.512 x 2 = 1.024  2-1 + 2-2 + 2-5 + 2-10
0.024 x 2 = 0.048  0.5 + 0.25 +0.03125 +
0.048 x 2 = 0.096 0.0009765625
0.192 x 2 = 0.384  0.7822265625
0.384 x 2 = 0.768
0.768 x 2 = 1.536
37
Decimal to Octal Conversion

Example (Integer) : (175)10


Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1
a0)8 = (257)8

Example (Fractional) : (0.3125) 10


Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
38
Practice Questions

• Convert the following from Decimals to Binary


» 259 , 245.50 , 89. 35
• Convert the following from Decimals to Octal
» 125 , 36.25 , 89. 45
• Convert the following from Binary to Hexadecimal
» 101100.01010101 , 1011011.0101
• Convert the following from Octal to hexadecimal
» 357 , 254.53 , 707. 135

39
Number Base Conversions : Practice Questions

• Convert the following from Decimal to Binary


Number System
– 25 , 30.25 , 19.125 , 36.333
• Convert the following from Decimal to Octal
Number System
– 59 , 77.50 , 89.140, 104.75
• Convert the following from Decimal
to Hexadecimal Number System
– 158 , 77.50 , 289.150

40
Exercise
2
 Convert these c)
system decimal (22.5)10=( ? )2
system numbers
numbers to
a) 17 binary 2222
11
b)38 0
c)22.5 2 5 1
d)
2 2 1
764.3
75 1
0
0.5 x 2 = 1.0
=> (22.5)10=(
10110.1 )2 41
Base X– to – Base Y
Conversion
 We can convert base x number to base y
number by following these steps :
🞑 Convert base x to base 10 (decimal system
number)
🞑 Then, convert decimal number to base y

42
Number Base Conversions
Sum of
(Digit x Weight)

Octal
(Base
8)
Sum of
(Digit x Weight)
?
Decimal Binary
(Base (Base
10) 2)

Hexadecimal
(Base 16)

9/16/2020
23 43
Octal to Hexadecimal
• Convert to Binary as an intermediate step i.e.
Convert from Octal to Binary to Hexadecimal

Example: ( 2 6 . 2 )8

Assume Zeros Assume Zeros

( 0 1 0 1 1 0 . 0 1 0 )2

(1 6 . 4
)16
Works both ways (Octal to Hex & Hex to Octal)
44
Exampl
e
 Convert 372.348 to hexadecimal system
number
🞑 Convert 372.348 to decimal system number
 372.348 = (3x82)+(7x81)+(2x80) . (3x8-1) + (4x8-2)
= 192 + 56 + 2 . 0.375 + 0.0625
= 250 . 4375
🞑 Convert 250.437510 to hexadecimal system
number
250 / 16 = 15 remainder 10
 250.4375 0.4375 * 16 = 7.0
10
250  number
Positional FA16 0.4375  0.716
Fractional number
372.348 = FA.716 45
Exercise 3 (TODO)

 Convert these numbers to octal system


number
🞑 11100.10012
🞑 1111112
🞑 5A.B16
 Convert these numbers to binary system
number
🞑 5A.B16
🞑 75.28

46
Number Base Conversion :
Binary, Octal, Hexadecimal to Decimal
• For Base Conversion from Binary, Octal and
Hexadecimal to Decimal use the Sum*Weight
formula
d *B 2+d *B 1+d *B 0 + d *B-1 +d *B-2
2 1 0 -1 -2

Integer Part

Fractional Part

• Binary to Decimal Conversion


116 0 1 0 1 8

4
1 *2 +0 *2 +1 *2 +0 *2 +1 *2
4 3 2 1 0
2
1
=(21)10
47
Number Base Conversion
(Decimal to Binary, Octal, Hexadecimal)

• For Integer part


– Divide the number by the "Base"
– Take the remainder as a Coefficient
– Take the quotient and Repeat division till
quotient is ZERO or Less than Base

• For Fractional part


– Multiply the number by Base
– Take integer part of result as coefficient
– Repeat the process with fractional part of result
till fraction is ZERO or desired accuracy is
achieved
48
Number Base Conversion – (Base R)

• For Integer part


– Divide the number by the "Base = R"
– Take the remainder as a Coefficient
– Take the quotient and Repeat division till
quotient is ZERO or Less than Base
• For Fractional part
– Multiply the number by "Base = R"
– Take integer part of result as coefficient
– Repeat the process with fractional part of result till
fraction is ZERO or desired accuracy is
achieved
• For conversion to decimal „Sum of WeightxDigit‟
49
Number Base Conversions : Practice Questions

• Convert the following from Decimal to Base = 4


– 15 , 25.45
• Convert the following from Decimal to Base = 7
– 17.50 , 29, 54.15
• Convert the following from Decimal to Base = 3
– 58 , 41.50
• Convert the following from Base = 6 to decimal
– (145)6 , (31.42) 6

50
Reading Assignment
• Read the following topics from Chapter 1 of
the
book
– 1.2 : Number systems
– 1.3 : Number base conversion
– 1.4 : Octal and Hexadecimal Numbers

51

You might also like