SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Computer & Network Technology

Chamila Fernando
02/03/14

Information Representation

BSc(Eng) Hons,MBA,MIEEE
1
Lecture 2: Number Systems & Codes
Number Systems
 Information Representations






Positional Notations
Decimal (base 10) Number System
Other Number Systems & Base-R to Decimal Conversion
Decimal-to-Binary Conversion
 Sum-of-Weights Method
 Repeated Division-by-2 Method (for whole numbers)
 Repeated Multiplication-by-2 Method (for fractions)

02/03/14

Information Representation

2
Lecture 2: Number Systems & Codes






Conversion between Decimal and other Bases
Conversion between Bases
Binary-Octal/Hexadecimal Conversion
Binary Arithmetic Operations
Negative Numbers Representation
 Sign-and-magtitude
 1s Complement
 2s Complement

 Comparison of Sign-and-Magnitude and Complements

02/03/14

Information Representation

3
Lecture 2: Number Systems & Codes
 Complements
 Diminished-Radix Complements
 Radix Complements







02/03/14

2s Complement Addition and Subtraction
1s Complement Addition and Subtraction
Overflow
Fixed-Point Numbers
Floating-Point Numbers
Arithmetics with Floating-Point Numbers

Information Representation

4
Lecture 2: Number Systems & Codes
Codes
 Binary Coded Decimal (BCD)

 Gray Code
 Binary-to-Gray Conversion
 Gray-to-Binary Conversion





02/03/14

Other Decimal Codes
Self-Complementing Codes
Alphanumeric Codes
Error Detection Codes
Information Representation

5
Information Representation
 Numbers are important to computers
 represent information precisely
 can be processed

 For example:
 to represent yes or no: use 0 for no and 1 for yes
 to represent 4 seasons: 0 (autumn), 1 (winter), 2(spring) and 3

(summer)

02/03/14

Information Representation

6
Information Representation
 Elementary storage units inside computer are electronic

switches. Each switch holds one of two states: on (1) or off
switches
(0).

ON

OFF

 We use a bit (binary digit), 0 or 1, to represent the state.
bi

02/03/14

Information Representation

7
Information Representation
 Storage units can be grouped together to cater for larger
range of numbers. Example: 2 switches to represent 4
values.
0 (00)
1 (01)
2 (10)
3 (11)

02/03/14

Information Representation

8
Information Representation
 In general, N bits can represent 2N different values.
 For M values,
 log 2 Mbits are needed.

1 bit → represents up to 2 values (0 or 1)
2 bits → rep. up to 4 values (00, 01, 10 or 11)
3 bits → rep. up to 8 values (000, 001, 010. …, 110, 111)
4 bits → rep. up to 16 values (0000, 0001, 0010, …, 1111)
32 values
→ requires 5 bits
64 values → requires 6 bits
1024 values → requires 10 bits
40 values → requires 6 bits
100 values → requires 7 bits
02/03/14

Information Representation

9
Positional Notations
 Position-independent notation
 each symbol denotes a value independent of its position: Egyptian

number system

 Relative-position notation
 Roman numerals symbols with different values: I (1), V (5), X (10), C

(50), M (100)
 Examples: I, II, III, IV, VI, VI, VII, VIII, IX
 Relative position important: IV = 4 but VI = 6

 Computations are difficult with the above two notations

02/03/14

Information Representation

10
Positional Notations
 Weighted-positional notation
 Decimal number system, symbols = { 0, 1, 2, 3, …, 9 }
 Position is important
 Example:(7594)10 = (7x103) + (5x102) + (9x101) + (4x100)
 The value of each symbol is dependent on its type and its position in

the number

 In general, (anan-1… a0)10 = (an x 10n) + (an-1 x 10n-1) + … + (a0 x 100)

02/03/14

Information Representation

11
Positional Notations
 Fractions are written in decimal numbers after the decimal
point.

 2 3 4 = (2.75)10 = (2 x 100) + (7 x 10-1) + (5 x 10-2)
 In general, (anan-1… a0 . f1f2 … fm)10 = (an x 10n) + (an-1x10n-1) + … + (a0 x 100) +

(f1 x 10-1) + (f2 x 10-2) + … + (fm x 10-m)

 The radix (or base) of the number system is the total
base
number of digits allowed in the system.

02/03/14

Information Representation

12
Decimal (base 10) Number System
 Weighting factors (or weights) are in powers-of-10:
… 103 102 101 100.10-1 10-2 10-3 10-4 …

 To evaluate the decimal number 593.68, the digit in each
position is multiplied by the corresponding weight:
5×102 + 9×101 + 3×100 + 6×10-1 + 8×10-2
(593.68)10

02/03/14

Information Representation

=

13
Other Number Systems &
Base-R to Decimal Conversion
 Binary (base 2): weights in powers-of-2.
– Binary digits (bits): 0,1.

 Octal (base 8): weights in powers-of-8.
– Octal digits: 0,1,2,3,4,5,6,7.

 Hexadecimal (base 16): weights in powers-of-16.
– Hexadecimal digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.

 Base R: weights in powers-of-R.

02/03/14

Information Representation

14
Other Number Systems &
Base-R to Decimal Conversion
 (1101.101)2 = 1×23 + 1×22 + 1×20 + 1×2-1 + 1×2-3
= 8 + 4 + 1 + 0.5 + 0.125 = (13.625)10

 (572.6)8 = 5×82 + 7×81 + 2×80 + 6×8-1
= 320 + 56 + 2 + 0.75 = (378.75)10

 (2A.8)16 = 2×161 + 10×160 + 8×16-1
= 32 + 10 + 0.5 = (42.5)10

 (341.24)5 = 3×52 + 4×51 + 1×50 + 2×5-1 + 4×5-2
= 75 + 20 + 1 + 0.4 + 0.16 = (96.56)10

02/03/14

Information Representation

15
Other Number Systems &
Base-R to Decimal Conversion
 Counting in Binary
 Assuming non-negative values, n



02/03/14

bits → largest value 2n – 1.
Examples: 4 bits → 0 to 15;
6 bits → 0 to 63.
range of m values → log2m bits

Information Representation

Decimal
Number
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Binary
Number
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1

0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1

0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1

0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
16
Decimal-to-Binary Conversion
 Method 1: Sum-of-Weights Method
 Method 2:
 Repeated Division-by-2 Method (for whole numbers)
 Repeated Multiplication-by-2 Method (for fractions)

02/03/14

Information Representation

18
Sum-of-Weights Method
 Determine the set of binary weights whose sum is equal
to the decimal number.

(9)10 = 8 + 1 = 23 + 20 = (1001)2
(18)10 = 16 + 2 = 24 + 21 = (10010)2
(58)10 = 32 + 16 + 8 + 2 = 25 + 24 + 23 + 21 = (111010)2
(0.625)10 = 0.5 + 0.125 = 2-1 + 2-3 = (0.101)2

02/03/14

Information Representation

19
Repeated Division-by-2 Method
 To convert a whole number to binary, use successive

division by 2 until the quotient is 0. The remainders form
the answer, with the first remainder as the least
significant bit (LSB) and the last as the most significant bit
(MSB).

(43)10 = (101011)2

02/03/14

2
2
2
2
2
2

43
21
10
5
2
1
0

Information Representation

rem 1  LSB
rem 1
rem 0
rem 1
rem 0
rem 1  MSB

20
Repeated Multiplication-by-2 Method
 To convert decimal fractions to binary, repeated

multiplication by 2 is used, until the fractional product is 0
(or until the desired number of decimal places). The
carried digits, or carries, produce the answer, with the
first carry as the MSB, and the last as the LSB.

(0.3125)10 = (.0101)2
0.3125×
2=0.625
0.625×
2=1.25
0.25×
2=0.50
0.5×
2=1.00
02/03/14

Information Representation

Carry
0
1
0
1

MSB

LSB
21
Conversion between Decimal and other
Bases
 Base-R to decimal: multiply digits with their corresponding
decimal
weights.

 Decimal to binary (base 2)
 whole numbers: repeated division-by-2
 fractions: repeated multiplication-by-2

 Decimal to base-R
 whole numbers: repeated division-by-R
 fractions: repeated multiplication-by-R

02/03/14

Information Representation

22
Conversion between Bases
 In general, conversion between bases can be done via
decimal:

Base-2
Base-3
Base-4
…
Base-R

Decimal

Base-2
Base-3
Base-4
….
Base-R

 Shortcuts for conversion between bases 2, 4, 8, 16.

02/03/14

Information Representation

24
Binary-Octal/Hexadecimal Conversion
 Binary → Octal: Partition in groups of 3
Octal
(10 111 011 001 . 101 110)2 = (2731.56)8

 Octal → Binary: reverse
Binary
(2731.56)8 = (10 111 011 001 . 101 110)2

 Binary → Hexadecimal: Partition in groups of 4
Hexadecimal
(101 1101 1001 . 1011 1000)2 = (5D9.B8)16

 Hexadecimal → Binary: reverse
Binary
(5D9.B8)16 = (101 1101 1001 . 1011 1000)2

02/03/14

Information Representation

25
Binary Arithmetic Operations
 ADDITION
 Like decimal numbers, two numbers can be added by

adding each pair of digits together with carry propagation.

(11011)2
+ (10011)2
(101110)2

02/03/14

Information Representation

(647)10
+ (537)10
(1184)10

27
Binary Arithmetic Operations
 Digit addition table:
BINARY
0+0+0=00
0+1+0=01

0+0+0=00
0+1+0=01

1+0+0=01
1+1+0=10
0+0+1=01

0+2+0=02
…
1+8+0=09

0+1+1=10

1+9+0=10

1+0+1=10

…

1+1+1=11

9+9+1=19

(11011)2
+ (10011)2
(101110)2

DECIMAL

1 0
0 1
0 1
1 0
0 1

0 1 1 0
1 0 1 1
0 0 1 1
1 1 1 0
0 0 1 1

Carry in
Carry out
02/03/14

Information Representation

28
Binary Arithmetic Operations
 SUBTRACTION
 Two numbers can be subtracted by subtracting each pair of
digits together with borrowing, where needed.

(11001)2
- (10011)2
(00110)2

02/03/14

Information Representation

(627)10
- (537)10
(090)10

29
Binary Arithmetic Operations
 Digit subtraction table:
BINARY

DECIMAL

0-0-0=00

0-0-0=00

0-1-0=11

0-1-0=19

1-0-0=01

0-2-0=18

1-1-0=00

…

0-0-1=11

0-9-1=10

0-1-1=10

1-0-1=00

1-0-1=00

…

1-1-1=11

9-9-1=19

(11001)2
- (10011)2
(00110)2
0 0 1
0 1 1
0 1 0
0 0 0
0 0 0

1 0 0
0 0 1
0 1 1
1 1 0
1 1 0

Borrow

02/03/14

Information Representation

30
Binary Arithmetic Operations
 MULTIPLICATION
 To multiply two numbers, take each digit of the multiplier
and multiply it with the multiplicand. This produces a
multiplicand
number of partial products which are then added.
(11001)2
x (10101)2
(11001)2
(11001)2
+(11001)2
(1000001101)2

02/03/14

(214)10
x (152)10
(428)10
(1070)10
+(214)10
(32528)10

Information Representation

Multiplicand
Multiplier
Partial
products
Result

31
Binary Arithmetic Operations
 Digit multiplication table:
BINARY

DECIMAL

0X0=0

0 X 0= 0

0 X 1= 0

0 X 1= 0

1X0=0

…

1 X 1= 1

1X8=8
1 X 9= 9
…
9 X 8 = 72
9 X 9 = 81

 DIVISION – can you figure out how this is done?
 Think of the division technique (shift & subtract) used for
decimal numbers and apply it to binary numbers.

02/03/14

Information Representation

32

Weitere ähnliche Inhalte

Was ist angesagt?

Ch1.number systems
Ch1.number systemsCh1.number systems
Ch1.number systemsteba
 
Number system
Number systemNumber system
Number systemSajib
 
Number System & Data Representation
Number System & Data RepresentationNumber System & Data Representation
Number System & Data RepresentationPhillip Glenn Libay
 
Introduction to Information Technology Lecture 2
Introduction to Information Technology Lecture 2Introduction to Information Technology Lecture 2
Introduction to Information Technology Lecture 2MikeCrea
 
Understand data representation on CPU 1
Understand data representation on CPU 1Understand data representation on CPU 1
Understand data representation on CPU 1Brenda Debra
 
Digital and Logic Design Chapter 1 binary_systems
Digital and Logic Design Chapter 1 binary_systemsDigital and Logic Design Chapter 1 binary_systems
Digital and Logic Design Chapter 1 binary_systemsImran Waris
 
Data representation
Data representationData representation
Data representationChew Hoong
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Number system computer fundamental
 Number  system computer fundamental  Number  system computer fundamental
Number system computer fundamental Aman anand kumar
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number systemtcc_joemarie
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersMohammad Bashartullah
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdfmiftah88
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpuWan Afirah
 

Was ist angesagt? (20)

Ch1.number systems
Ch1.number systemsCh1.number systems
Ch1.number systems
 
Number system
Number systemNumber system
Number system
 
Number System & Data Representation
Number System & Data RepresentationNumber System & Data Representation
Number System & Data Representation
 
Introduction to Information Technology Lecture 2
Introduction to Information Technology Lecture 2Introduction to Information Technology Lecture 2
Introduction to Information Technology Lecture 2
 
Understand data representation on CPU 1
Understand data representation on CPU 1Understand data representation on CPU 1
Understand data representation on CPU 1
 
Digital and Logic Design Chapter 1 binary_systems
Digital and Logic Design Chapter 1 binary_systemsDigital and Logic Design Chapter 1 binary_systems
Digital and Logic Design Chapter 1 binary_systems
 
Ch3
Ch3Ch3
Ch3
 
Data representation
Data representationData representation
Data representation
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Number system 1
Number system 1Number system 1
Number system 1
 
Number system
Number systemNumber system
Number system
 
Number system computer fundamental
 Number  system computer fundamental  Number  system computer fundamental
Number system computer fundamental
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number system
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
Computer Number System
Computer Number SystemComputer Number System
Computer Number System
 
Binary number systems
Binary number systemsBinary number systems
Binary number systems
 
Number System
Number SystemNumber System
Number System
 
Number system
Number systemNumber system
Number system
 
2.1 data represent on cpu
2.1 data represent on cpu2.1 data represent on cpu
2.1 data represent on cpu
 

Ähnlich wie Lecture 2

FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...Arti Parab Academics
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptxAliaaTarek5
 
Chapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptChapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptAparnaDas827261
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxKUMARS641064
 
Computer organiztion2
Computer organiztion2Computer organiztion2
Computer organiztion2Umang Gupta
 
1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptxLibanMohamed26
 
Chapter two FHI.pptx
Chapter two FHI.pptxChapter two FHI.pptx
Chapter two FHI.pptxODAATUBE1
 
digi.elec.number%20system.pptx
digi.elec.number%20system.pptxdigi.elec.number%20system.pptx
digi.elec.number%20system.pptxansariparveen06
 
Number system by ammar nawab
Number system by ammar nawabNumber system by ammar nawab
Number system by ammar nawabAmmar_n
 

Ähnlich wie Lecture 2 (20)

DCF QNA edited
DCF QNA editedDCF QNA edited
DCF QNA edited
 
2013 1
2013 1 2013 1
2013 1
 
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
FYBSC IT Digital Electronics Unit I Chapter I Number System and Binary Arithm...
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptx
 
Number Systems
Number  SystemsNumber  Systems
Number Systems
 
Chapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.pptChapter 1 Digital Systems and Binary Numbers.ppt
Chapter 1 Digital Systems and Binary Numbers.ppt
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptx
 
DLD-Introduction.pptx
DLD-Introduction.pptxDLD-Introduction.pptx
DLD-Introduction.pptx
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Digital Electronics Notes.pdf
Digital Electronics Notes.pdfDigital Electronics Notes.pdf
Digital Electronics Notes.pdf
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Computer organiztion2
Computer organiztion2Computer organiztion2
Computer organiztion2
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx1.Digital Electronics overview & Number Systems.pptx
1.Digital Electronics overview & Number Systems.pptx
 
Chapter two FHI.pptx
Chapter two FHI.pptxChapter two FHI.pptx
Chapter two FHI.pptx
 
Number system
Number systemNumber system
Number system
 
digi.elec.number%20system.pptx
digi.elec.number%20system.pptxdigi.elec.number%20system.pptx
digi.elec.number%20system.pptx
 
Number system by ammar nawab
Number system by ammar nawabNumber system by ammar nawab
Number system by ammar nawab
 
Chapter 1
Chapter   1Chapter   1
Chapter 1
 

Kürzlich hochgeladen

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 

Kürzlich hochgeladen (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Lecture 2

  • 1. Computer & Network Technology Chamila Fernando 02/03/14 Information Representation BSc(Eng) Hons,MBA,MIEEE 1
  • 2. Lecture 2: Number Systems & Codes Number Systems  Information Representations     Positional Notations Decimal (base 10) Number System Other Number Systems & Base-R to Decimal Conversion Decimal-to-Binary Conversion  Sum-of-Weights Method  Repeated Division-by-2 Method (for whole numbers)  Repeated Multiplication-by-2 Method (for fractions) 02/03/14 Information Representation 2
  • 3. Lecture 2: Number Systems & Codes      Conversion between Decimal and other Bases Conversion between Bases Binary-Octal/Hexadecimal Conversion Binary Arithmetic Operations Negative Numbers Representation  Sign-and-magtitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude and Complements 02/03/14 Information Representation 3
  • 4. Lecture 2: Number Systems & Codes  Complements  Diminished-Radix Complements  Radix Complements       02/03/14 2s Complement Addition and Subtraction 1s Complement Addition and Subtraction Overflow Fixed-Point Numbers Floating-Point Numbers Arithmetics with Floating-Point Numbers Information Representation 4
  • 5. Lecture 2: Number Systems & Codes Codes  Binary Coded Decimal (BCD)  Gray Code  Binary-to-Gray Conversion  Gray-to-Binary Conversion     02/03/14 Other Decimal Codes Self-Complementing Codes Alphanumeric Codes Error Detection Codes Information Representation 5
  • 6. Information Representation  Numbers are important to computers  represent information precisely  can be processed  For example:  to represent yes or no: use 0 for no and 1 for yes  to represent 4 seasons: 0 (autumn), 1 (winter), 2(spring) and 3 (summer) 02/03/14 Information Representation 6
  • 7. Information Representation  Elementary storage units inside computer are electronic switches. Each switch holds one of two states: on (1) or off switches (0). ON OFF  We use a bit (binary digit), 0 or 1, to represent the state. bi 02/03/14 Information Representation 7
  • 8. Information Representation  Storage units can be grouped together to cater for larger range of numbers. Example: 2 switches to represent 4 values. 0 (00) 1 (01) 2 (10) 3 (11) 02/03/14 Information Representation 8
  • 9. Information Representation  In general, N bits can represent 2N different values.  For M values,  log 2 Mbits are needed.  1 bit → represents up to 2 values (0 or 1) 2 bits → rep. up to 4 values (00, 01, 10 or 11) 3 bits → rep. up to 8 values (000, 001, 010. …, 110, 111) 4 bits → rep. up to 16 values (0000, 0001, 0010, …, 1111) 32 values → requires 5 bits 64 values → requires 6 bits 1024 values → requires 10 bits 40 values → requires 6 bits 100 values → requires 7 bits 02/03/14 Information Representation 9
  • 10. Positional Notations  Position-independent notation  each symbol denotes a value independent of its position: Egyptian number system  Relative-position notation  Roman numerals symbols with different values: I (1), V (5), X (10), C (50), M (100)  Examples: I, II, III, IV, VI, VI, VII, VIII, IX  Relative position important: IV = 4 but VI = 6  Computations are difficult with the above two notations 02/03/14 Information Representation 10
  • 11. Positional Notations  Weighted-positional notation  Decimal number system, symbols = { 0, 1, 2, 3, …, 9 }  Position is important  Example:(7594)10 = (7x103) + (5x102) + (9x101) + (4x100)  The value of each symbol is dependent on its type and its position in the number  In general, (anan-1… a0)10 = (an x 10n) + (an-1 x 10n-1) + … + (a0 x 100) 02/03/14 Information Representation 11
  • 12. Positional Notations  Fractions are written in decimal numbers after the decimal point.  2 3 4 = (2.75)10 = (2 x 100) + (7 x 10-1) + (5 x 10-2)  In general, (anan-1… a0 . f1f2 … fm)10 = (an x 10n) + (an-1x10n-1) + … + (a0 x 100) + (f1 x 10-1) + (f2 x 10-2) + … + (fm x 10-m)  The radix (or base) of the number system is the total base number of digits allowed in the system. 02/03/14 Information Representation 12
  • 13. Decimal (base 10) Number System  Weighting factors (or weights) are in powers-of-10: … 103 102 101 100.10-1 10-2 10-3 10-4 …  To evaluate the decimal number 593.68, the digit in each position is multiplied by the corresponding weight: 5×102 + 9×101 + 3×100 + 6×10-1 + 8×10-2 (593.68)10 02/03/14 Information Representation = 13
  • 14. Other Number Systems & Base-R to Decimal Conversion  Binary (base 2): weights in powers-of-2. – Binary digits (bits): 0,1.  Octal (base 8): weights in powers-of-8. – Octal digits: 0,1,2,3,4,5,6,7.  Hexadecimal (base 16): weights in powers-of-16. – Hexadecimal digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.  Base R: weights in powers-of-R. 02/03/14 Information Representation 14
  • 15. Other Number Systems & Base-R to Decimal Conversion  (1101.101)2 = 1×23 + 1×22 + 1×20 + 1×2-1 + 1×2-3 = 8 + 4 + 1 + 0.5 + 0.125 = (13.625)10  (572.6)8 = 5×82 + 7×81 + 2×80 + 6×8-1 = 320 + 56 + 2 + 0.75 = (378.75)10  (2A.8)16 = 2×161 + 10×160 + 8×16-1 = 32 + 10 + 0.5 = (42.5)10  (341.24)5 = 3×52 + 4×51 + 1×50 + 2×5-1 + 4×5-2 = 75 + 20 + 1 + 0.4 + 0.16 = (96.56)10 02/03/14 Information Representation 15
  • 16. Other Number Systems & Base-R to Decimal Conversion  Counting in Binary  Assuming non-negative values, n  02/03/14 bits → largest value 2n – 1. Examples: 4 bits → 0 to 15; 6 bits → 0 to 63. range of m values → log2m bits Information Representation Decimal Number 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Binary Number 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 16
  • 17. Decimal-to-Binary Conversion  Method 1: Sum-of-Weights Method  Method 2:  Repeated Division-by-2 Method (for whole numbers)  Repeated Multiplication-by-2 Method (for fractions) 02/03/14 Information Representation 18
  • 18. Sum-of-Weights Method  Determine the set of binary weights whose sum is equal to the decimal number. (9)10 = 8 + 1 = 23 + 20 = (1001)2 (18)10 = 16 + 2 = 24 + 21 = (10010)2 (58)10 = 32 + 16 + 8 + 2 = 25 + 24 + 23 + 21 = (111010)2 (0.625)10 = 0.5 + 0.125 = 2-1 + 2-3 = (0.101)2 02/03/14 Information Representation 19
  • 19. Repeated Division-by-2 Method  To convert a whole number to binary, use successive division by 2 until the quotient is 0. The remainders form the answer, with the first remainder as the least significant bit (LSB) and the last as the most significant bit (MSB). (43)10 = (101011)2 02/03/14 2 2 2 2 2 2 43 21 10 5 2 1 0 Information Representation rem 1  LSB rem 1 rem 0 rem 1 rem 0 rem 1  MSB 20
  • 20. Repeated Multiplication-by-2 Method  To convert decimal fractions to binary, repeated multiplication by 2 is used, until the fractional product is 0 (or until the desired number of decimal places). The carried digits, or carries, produce the answer, with the first carry as the MSB, and the last as the LSB. (0.3125)10 = (.0101)2 0.3125× 2=0.625 0.625× 2=1.25 0.25× 2=0.50 0.5× 2=1.00 02/03/14 Information Representation Carry 0 1 0 1 MSB LSB 21
  • 21. Conversion between Decimal and other Bases  Base-R to decimal: multiply digits with their corresponding decimal weights.  Decimal to binary (base 2)  whole numbers: repeated division-by-2  fractions: repeated multiplication-by-2  Decimal to base-R  whole numbers: repeated division-by-R  fractions: repeated multiplication-by-R 02/03/14 Information Representation 22
  • 22. Conversion between Bases  In general, conversion between bases can be done via decimal: Base-2 Base-3 Base-4 … Base-R Decimal Base-2 Base-3 Base-4 …. Base-R  Shortcuts for conversion between bases 2, 4, 8, 16. 02/03/14 Information Representation 24
  • 23. Binary-Octal/Hexadecimal Conversion  Binary → Octal: Partition in groups of 3 Octal (10 111 011 001 . 101 110)2 = (2731.56)8  Octal → Binary: reverse Binary (2731.56)8 = (10 111 011 001 . 101 110)2  Binary → Hexadecimal: Partition in groups of 4 Hexadecimal (101 1101 1001 . 1011 1000)2 = (5D9.B8)16  Hexadecimal → Binary: reverse Binary (5D9.B8)16 = (101 1101 1001 . 1011 1000)2 02/03/14 Information Representation 25
  • 24. Binary Arithmetic Operations  ADDITION  Like decimal numbers, two numbers can be added by adding each pair of digits together with carry propagation. (11011)2 + (10011)2 (101110)2 02/03/14 Information Representation (647)10 + (537)10 (1184)10 27
  • 25. Binary Arithmetic Operations  Digit addition table: BINARY 0+0+0=00 0+1+0=01 0+0+0=00 0+1+0=01 1+0+0=01 1+1+0=10 0+0+1=01 0+2+0=02 … 1+8+0=09 0+1+1=10 1+9+0=10 1+0+1=10 … 1+1+1=11 9+9+1=19 (11011)2 + (10011)2 (101110)2 DECIMAL 1 0 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 1 0 0 1 1 1 1 1 0 0 0 1 1 Carry in Carry out 02/03/14 Information Representation 28
  • 26. Binary Arithmetic Operations  SUBTRACTION  Two numbers can be subtracted by subtracting each pair of digits together with borrowing, where needed. (11001)2 - (10011)2 (00110)2 02/03/14 Information Representation (627)10 - (537)10 (090)10 29
  • 27. Binary Arithmetic Operations  Digit subtraction table: BINARY DECIMAL 0-0-0=00 0-0-0=00 0-1-0=11 0-1-0=19 1-0-0=01 0-2-0=18 1-1-0=00 … 0-0-1=11 0-9-1=10 0-1-1=10 1-0-1=00 1-0-1=00 … 1-1-1=11 9-9-1=19 (11001)2 - (10011)2 (00110)2 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0 Borrow 02/03/14 Information Representation 30
  • 28. Binary Arithmetic Operations  MULTIPLICATION  To multiply two numbers, take each digit of the multiplier and multiply it with the multiplicand. This produces a multiplicand number of partial products which are then added. (11001)2 x (10101)2 (11001)2 (11001)2 +(11001)2 (1000001101)2 02/03/14 (214)10 x (152)10 (428)10 (1070)10 +(214)10 (32528)10 Information Representation Multiplicand Multiplier Partial products Result 31
  • 29. Binary Arithmetic Operations  Digit multiplication table: BINARY DECIMAL 0X0=0 0 X 0= 0 0 X 1= 0 0 X 1= 0 1X0=0 … 1 X 1= 1 1X8=8 1 X 9= 9 … 9 X 8 = 72 9 X 9 = 81  DIVISION – can you figure out how this is done?  Think of the division technique (shift & subtract) used for decimal numbers and apply it to binary numbers. 02/03/14 Information Representation 32