SlideShare uma empresa Scribd logo
1 de 23
CS304PC:Computer Organization
and Architecture (R18 II(I sem))
Department of computer science and engineering
(AI/ML)
Session 17
by
Asst.Prof.M.Gokilavani
VITS
2/3/2023 Department of CSE (AI/ML) 1
TEXTBOOK:
• 1. Computer System Architecture – M. Moris Mano, Third Edition,
Pearson/PHI.
REFERENCES:
• Computer Organization – Car Hamacher, Zvonks Vranesic, Safea
Zaky, Vth Edition, McGraw Hill.
• Computer Organization and Architecture – William Stallings Sixth
Edition, Pearson/PHI.
• Structured Computer Organization – Andrew S. Tanenbaum, 4th
Edition, PHI/Pearson.
2/3/2023 Department of CSE (AI/ML) 2
Unit III
Data Representation: Data types ,Complements, fixed point
Representations, Floating point representation.
Computer Arithmetic: Addition and subtraction,
multiplication Algorithms, Division Algorithms, Floating-point
Arithmetic operations, Decimal Arithmetic unit, Decimal
Arithmetic operations.
2/3/2023 Department of CSE (AI/ML) 3
Topics covered in session 17
2/3/2023 Department of CSE (AI/ML) 4
• Data types
• Complements
• Fixed point Representations
• Floating point representations
Complements
• Complements are used in digital computers for simplifying the
subtraction operation and for logical manipulation.
• There are two types of complements for each base r system:
• R’s complement (2’s and 10’s complements)
• (r-1)’s complement (1’s and 9’s complements)
• When the value of the base r is substituted in the name, the two types
are referred to as the 2’s and 1’s complement for binary numbers and
the 10’s and 9’s complement for decimal numbers.
2/3/2023 Department of CSE (AI/ML) 5
(r-1)’s complements
i. 9’s Complement: Given a number N in base r having n digits, the (r – 1)’s
complement of N is defined as (rn – 1) – N .
• For decimal, the 9’s complement of N is (10n – 1) – N.
For Example,
• The 9’s complement of 546700 is 999999 – 546700 = 453299
• The 9’s complement of 453299 is 999999 – 453299 = 546700
ii. 1’s complement: For binary, the 1’s complement of N is (2n – 1) – N .
For example,
• The 1’s complement of 1011001 is 1111111 – 1011001 = 0100110
2/3/2023 Department of CSE (AI/ML) 6
(r’s) Complement
10’s and 2’s complement : The r’s complement of an n-digit number N
in base r is defined as rn – N .
• This is the same as adding 1 to the (r – 1)’s complement
For example,
• The 10’s complement of 2389 is 7610 + 1 = 7611
• The 2’s complement of 101100 is 010011 + 1 = 010100
2/3/2023 Department of CSE (AI/ML) 7
Questions
1.
2.
3.
2/3/2023 Department of CSE (AI/ML) 8
Subtraction of unsigned numbers
2/3/2023 Department of CSE (AI/ML) 9
Sample problem 1
2/3/2023 Department of CSE (AI/ML) 10
Sample problem 2
2/3/2023 Department of CSE (AI/ML) 11
Questions
1.
2.
2/3/2023 Department of CSE (AI/ML) 12
Fixed point Representation
• Positive integers and zero can be represented by unsigned numbers
• Negative numbers must be represented by signed numbers since + and –
signs are not available, only 1’s and 0’s are
• Signed numbers have msb as 0 for positive and 1 for negative – msb is the
sign bit
• Two ways to designate binary point position in a register
• Fixed point position
• Floating-point representation
• Fixed point position usually uses one of the two following positions
• A binary point in the extreme left of the register to make it a fraction
• A binary point in the extreme right of the register to make it an
integer
• In both cases, a binary point is not actually present
• The floating-point representations uses a second register to designate the
position of the binary point in the first register
2/3/2023 Department of CSE (AI/ML) 13
Integer Representation
• When an integer is positive, the msb, or sign bit, is 0 and the
remaining bits represent the magnitude
• When an integer is negative, the msb, or sign bit, is 1, but the rest of
the number can be represented in one of three ways
• Signed-magnitude representation
• Signed-1’s complement representation
• Signed-2’s complement representation
2/3/2023 Department of CSE (AI/ML) 14
Example
For Example, Consider an 8-bit register and the number +14
The only way to represent it is 0000 1110 (8 bits)
Similarly for integer representation,
Consider an 8-bit register and the number –14
Signed magnitude: 1 0001110
Signed 1’s complement: 1 1110001
Signed 2’s complement: 1 1110010
2/3/2023 Department of CSE (AI/ML) 15
Arithmetic Addition
• Addition of two signed-magnitude numbers follow the normal
rules
• If same signs, add the two magnitudes and use the common sign
• Differing signs, subtract the smaller from the larger and use the
sign of the larger magnitude
• Must compare the signs and magnitudes and then either add or
subtract
Example:
2/3/2023 Department of CSE (AI/ML) 16
Arithmetic Addition
• Addition of two signed 2’s complement numbers does not require
a comparison or subtraction – only addition and complementation
• Add the two numbers, including their sign bits
• Discard any carry out of the sign bit position
• All negative numbers must be in the 2’s complement form
• If the sum obtained is negative, then it is in 2’s complement
form.
Example:
2/3/2023 Department of CSE (AI/ML) 17
Arithmetic Subtraction
• Subtraction of two signed 2’s complement numbers is as follows
• Take the 2’s complement form of the subtrahend (including sign
bit)
• Add it to the minuend (including the sign bit)
• A carry out of the sign bit position is discarded
Example:
2/3/2023 Department of CSE (AI/ML) 18
Questions
2/3/2023 Department of CSE (AI/ML) 19
Overflow
• An overflow occurs when two numbers of n digits each are added and the sum
occupies n + 1 digits
• Overflows are problems since the width of a register is finite
• Therefore, a flag is set if this occurs and can be checked by the user
• Detection of an overflow depends on if the numbers are signed or unsigned
• For unsigned numbers, an overflow is detected from the end carry out of the msb
• For addition of signed numbers, an overflow cannot occur if one is positive and
one is negative – both have to have the same sign
• An overflow can be detected if the carry into the sign bit position and the carry out
of the sign bit position are not equal
Example:
2/3/2023 Department of CSE (AI/ML) 20
Decimal Fixed point representation
• The representation of decimal numbers in registers is a function of the
binary code used to represent a decimal digit
• A 4-bit decimal code requires four flip-flops for each decimal digit.
• This takes much more space than the equivalent binary representation and
the circuits required to perform decimal arithmetic are more complex.
• Representation of signed decimal numbers in BCD is similar to the
representation of signed numbers in binary.
• Either signed magnitude or signed complement systems .
• The sign of a number is represented with four bits
• 0000 for +
• 1001 for –
• To obtain the 10’s complement of a BCD number, first take the 9’s
complement and then add one to the least significant digits
2/3/2023 Department of CSE (AI/ML) 21
Example
Example: (+375) + (-240) = +135 done in signed 10’s Complement
System
2/3/2023 Department of CSE (AI/ML) 22
Topics to be covered in next session 18
• Floating point representations
2/3/2023 Department of CSE (AI/ML) 23
Thank you!!!

Mais conteúdo relacionado

Mais procurados

32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlays
myrajendra
 

Mais procurados (20)

Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU)
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
 
Cs419 lec10 left recursion and left factoring
Cs419 lec10   left recursion and left factoringCs419 lec10   left recursion and left factoring
Cs419 lec10 left recursion and left factoring
 
register
registerregister
register
 
Address calculation-sort
Address calculation-sortAddress calculation-sort
Address calculation-sort
 
Simulated Annealing
Simulated AnnealingSimulated Annealing
Simulated Annealing
 
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
 
File in C language
File in C languageFile in C language
File in C language
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 
Status register
Status registerStatus register
Status register
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 
Introduction to Compiler design
Introduction to Compiler design Introduction to Compiler design
Introduction to Compiler design
 
Computability and Complexity
Computability and ComplexityComputability and Complexity
Computability and Complexity
 
Phases of Compiler
Phases of CompilerPhases of Compiler
Phases of Compiler
 
Computer registers
Computer registersComputer registers
Computer registers
 
Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing files
 
32 dynamic linking nd overlays
32 dynamic linking nd overlays32 dynamic linking nd overlays
32 dynamic linking nd overlays
 
Lecture 14 run time environment
Lecture 14 run time environmentLecture 14 run time environment
Lecture 14 run time environment
 
Macro Processor
Macro ProcessorMacro Processor
Macro Processor
 
Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)Performance analysis(Time & Space Complexity)
Performance analysis(Time & Space Complexity)
 

Semelhante a CS304PC:Computer Organization and Architecture Session 17 Complements and fixed points representations.pptx

Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
IIUM
 

Semelhante a CS304PC:Computer Organization and Architecture Session 17 Complements and fixed points representations.pptx (20)

CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
CS304PC:Computer Organization and Architecture Session 19 Addition and subtra...
 
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdfCS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
 
CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...CS304PC:Computer Organization and Architecture session 22 floating point arit...
CS304PC:Computer Organization and Architecture session 22 floating point arit...
 
CS304PC:Computer Organization and Architecture Session 23 Decimal Arithmetic ...
CS304PC:Computer Organization and Architecture Session 23 Decimal Arithmetic ...CS304PC:Computer Organization and Architecture Session 23 Decimal Arithmetic ...
CS304PC:Computer Organization and Architecture Session 23 Decimal Arithmetic ...
 
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)Csc1401   lecture03 - computer arithmetic - arithmetic and logic unit (alu)
Csc1401 lecture03 - computer arithmetic - arithmetic and logic unit (alu)
 
CS304PC:Computer Organization and Architecture Session 16 data Representation...
CS304PC:Computer Organization and Architecture Session 16 data Representation...CS304PC:Computer Organization and Architecture Session 16 data Representation...
CS304PC:Computer Organization and Architecture Session 16 data Representation...
 
CS304PC:Computer Organization and Architecture Session 21 Division Algorithm....
CS304PC:Computer Organization and Architecture Session 21 Division Algorithm....CS304PC:Computer Organization and Architecture Session 21 Division Algorithm....
CS304PC:Computer Organization and Architecture Session 21 Division Algorithm....
 
CS304PC:Computer Organization and Architecture session 18 floating point rese...
CS304PC:Computer Organization and Architecture session 18 floating point rese...CS304PC:Computer Organization and Architecture session 18 floating point rese...
CS304PC:Computer Organization and Architecture session 18 floating point rese...
 
DLD_Chapter_2.pptx
DLD_Chapter_2.pptxDLD_Chapter_2.pptx
DLD_Chapter_2.pptx
 
Module 2_Data representations.pdf
Module 2_Data representations.pdfModule 2_Data representations.pdf
Module 2_Data representations.pdf
 
CS304PC:Computer Organization and Architecture Session 20 Multiplication algo...
CS304PC:Computer Organization and Architecture Session 20 Multiplication algo...CS304PC:Computer Organization and Architecture Session 20 Multiplication algo...
CS304PC:Computer Organization and Architecture Session 20 Multiplication algo...
 
Digital fundamendals r001a
Digital fundamendals r001aDigital fundamendals r001a
Digital fundamendals r001a
 
datareprersentation 1.pptx
datareprersentation 1.pptxdatareprersentation 1.pptx
datareprersentation 1.pptx
 
CS304PC:Computer Organization and Architecture session 20 Multiplication algo...
CS304PC:Computer Organization and Architecture session 20 Multiplication algo...CS304PC:Computer Organization and Architecture session 20 Multiplication algo...
CS304PC:Computer Organization and Architecture session 20 Multiplication algo...
 
index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
 
Unit 2 Arithmetic
Unit 2 ArithmeticUnit 2 Arithmetic
Unit 2 Arithmetic
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
 
Finite word length effects
Finite word length effectsFinite word length effects
Finite word length effects
 
Computer Oraganizaation.pptx
Computer Oraganizaation.pptxComputer Oraganizaation.pptx
Computer Oraganizaation.pptx
 
Pptdec2
Pptdec2Pptdec2
Pptdec2
 

Mais de Asst.prof M.Gokilavani

Mais de Asst.prof M.Gokilavani (20)

CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
IT8073_Information Security_UNIT I _.pdf
IT8073_Information Security_UNIT I _.pdfIT8073_Information Security_UNIT I _.pdf
IT8073_Information Security_UNIT I _.pdf
 
IT8073 _Information Security _UNIT I Full notes
IT8073 _Information Security _UNIT I Full notesIT8073 _Information Security _UNIT I Full notes
IT8073 _Information Security _UNIT I Full notes
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
 
GE3151 PSPP UNIT III QUESTION BANK.docx.pdf
GE3151 PSPP UNIT III QUESTION BANK.docx.pdfGE3151 PSPP UNIT III QUESTION BANK.docx.pdf
GE3151 PSPP UNIT III QUESTION BANK.docx.pdf
 
GE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdfGE3151 UNIT II Study material .pdf
GE3151 UNIT II Study material .pdf
 
GE3151 PSPP All unit question bank.pdf
GE3151 PSPP All unit question bank.pdfGE3151 PSPP All unit question bank.pdf
GE3151 PSPP All unit question bank.pdf
 
GE3151_PSPP_All unit _Notes
GE3151_PSPP_All unit _NotesGE3151_PSPP_All unit _Notes
GE3151_PSPP_All unit _Notes
 
GE3151_PSPP_UNIT_5_Notes
GE3151_PSPP_UNIT_5_NotesGE3151_PSPP_UNIT_5_Notes
GE3151_PSPP_UNIT_5_Notes
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
GE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_NotesGE3151_PSPP_UNIT_3_Notes
GE3151_PSPP_UNIT_3_Notes
 
GE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_NotesGE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_Notes
 
AI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdfAI3391 Artificial intelligence Unit IV Notes _ merged.pdf
AI3391 Artificial intelligence Unit IV Notes _ merged.pdf
 
AI3391 Artificial intelligence Session 29 Forward and backward chaining.pdf
AI3391 Artificial intelligence Session 29 Forward and backward chaining.pdfAI3391 Artificial intelligence Session 29 Forward and backward chaining.pdf
AI3391 Artificial intelligence Session 29 Forward and backward chaining.pdf
 
AI3391 Artificial intelligence Session 28 Resolution.pptx
AI3391 Artificial intelligence Session 28 Resolution.pptxAI3391 Artificial intelligence Session 28 Resolution.pptx
AI3391 Artificial intelligence Session 28 Resolution.pptx
 
AI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptxAI3391 Artificial intelligence session 27 inference and unification.pptx
AI3391 Artificial intelligence session 27 inference and unification.pptx
 
AI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptxAI3391 Artificial Intelligence Session 26 First order logic.pptx
AI3391 Artificial Intelligence Session 26 First order logic.pptx
 

Último

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 

Último (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 

CS304PC:Computer Organization and Architecture Session 17 Complements and fixed points representations.pptx

  • 1. CS304PC:Computer Organization and Architecture (R18 II(I sem)) Department of computer science and engineering (AI/ML) Session 17 by Asst.Prof.M.Gokilavani VITS 2/3/2023 Department of CSE (AI/ML) 1
  • 2. TEXTBOOK: • 1. Computer System Architecture – M. Moris Mano, Third Edition, Pearson/PHI. REFERENCES: • Computer Organization – Car Hamacher, Zvonks Vranesic, Safea Zaky, Vth Edition, McGraw Hill. • Computer Organization and Architecture – William Stallings Sixth Edition, Pearson/PHI. • Structured Computer Organization – Andrew S. Tanenbaum, 4th Edition, PHI/Pearson. 2/3/2023 Department of CSE (AI/ML) 2
  • 3. Unit III Data Representation: Data types ,Complements, fixed point Representations, Floating point representation. Computer Arithmetic: Addition and subtraction, multiplication Algorithms, Division Algorithms, Floating-point Arithmetic operations, Decimal Arithmetic unit, Decimal Arithmetic operations. 2/3/2023 Department of CSE (AI/ML) 3
  • 4. Topics covered in session 17 2/3/2023 Department of CSE (AI/ML) 4 • Data types • Complements • Fixed point Representations • Floating point representations
  • 5. Complements • Complements are used in digital computers for simplifying the subtraction operation and for logical manipulation. • There are two types of complements for each base r system: • R’s complement (2’s and 10’s complements) • (r-1)’s complement (1’s and 9’s complements) • When the value of the base r is substituted in the name, the two types are referred to as the 2’s and 1’s complement for binary numbers and the 10’s and 9’s complement for decimal numbers. 2/3/2023 Department of CSE (AI/ML) 5
  • 6. (r-1)’s complements i. 9’s Complement: Given a number N in base r having n digits, the (r – 1)’s complement of N is defined as (rn – 1) – N . • For decimal, the 9’s complement of N is (10n – 1) – N. For Example, • The 9’s complement of 546700 is 999999 – 546700 = 453299 • The 9’s complement of 453299 is 999999 – 453299 = 546700 ii. 1’s complement: For binary, the 1’s complement of N is (2n – 1) – N . For example, • The 1’s complement of 1011001 is 1111111 – 1011001 = 0100110 2/3/2023 Department of CSE (AI/ML) 6
  • 7. (r’s) Complement 10’s and 2’s complement : The r’s complement of an n-digit number N in base r is defined as rn – N . • This is the same as adding 1 to the (r – 1)’s complement For example, • The 10’s complement of 2389 is 7610 + 1 = 7611 • The 2’s complement of 101100 is 010011 + 1 = 010100 2/3/2023 Department of CSE (AI/ML) 7
  • 9. Subtraction of unsigned numbers 2/3/2023 Department of CSE (AI/ML) 9
  • 10. Sample problem 1 2/3/2023 Department of CSE (AI/ML) 10
  • 11. Sample problem 2 2/3/2023 Department of CSE (AI/ML) 11
  • 13. Fixed point Representation • Positive integers and zero can be represented by unsigned numbers • Negative numbers must be represented by signed numbers since + and – signs are not available, only 1’s and 0’s are • Signed numbers have msb as 0 for positive and 1 for negative – msb is the sign bit • Two ways to designate binary point position in a register • Fixed point position • Floating-point representation • Fixed point position usually uses one of the two following positions • A binary point in the extreme left of the register to make it a fraction • A binary point in the extreme right of the register to make it an integer • In both cases, a binary point is not actually present • The floating-point representations uses a second register to designate the position of the binary point in the first register 2/3/2023 Department of CSE (AI/ML) 13
  • 14. Integer Representation • When an integer is positive, the msb, or sign bit, is 0 and the remaining bits represent the magnitude • When an integer is negative, the msb, or sign bit, is 1, but the rest of the number can be represented in one of three ways • Signed-magnitude representation • Signed-1’s complement representation • Signed-2’s complement representation 2/3/2023 Department of CSE (AI/ML) 14
  • 15. Example For Example, Consider an 8-bit register and the number +14 The only way to represent it is 0000 1110 (8 bits) Similarly for integer representation, Consider an 8-bit register and the number –14 Signed magnitude: 1 0001110 Signed 1’s complement: 1 1110001 Signed 2’s complement: 1 1110010 2/3/2023 Department of CSE (AI/ML) 15
  • 16. Arithmetic Addition • Addition of two signed-magnitude numbers follow the normal rules • If same signs, add the two magnitudes and use the common sign • Differing signs, subtract the smaller from the larger and use the sign of the larger magnitude • Must compare the signs and magnitudes and then either add or subtract Example: 2/3/2023 Department of CSE (AI/ML) 16
  • 17. Arithmetic Addition • Addition of two signed 2’s complement numbers does not require a comparison or subtraction – only addition and complementation • Add the two numbers, including their sign bits • Discard any carry out of the sign bit position • All negative numbers must be in the 2’s complement form • If the sum obtained is negative, then it is in 2’s complement form. Example: 2/3/2023 Department of CSE (AI/ML) 17
  • 18. Arithmetic Subtraction • Subtraction of two signed 2’s complement numbers is as follows • Take the 2’s complement form of the subtrahend (including sign bit) • Add it to the minuend (including the sign bit) • A carry out of the sign bit position is discarded Example: 2/3/2023 Department of CSE (AI/ML) 18
  • 20. Overflow • An overflow occurs when two numbers of n digits each are added and the sum occupies n + 1 digits • Overflows are problems since the width of a register is finite • Therefore, a flag is set if this occurs and can be checked by the user • Detection of an overflow depends on if the numbers are signed or unsigned • For unsigned numbers, an overflow is detected from the end carry out of the msb • For addition of signed numbers, an overflow cannot occur if one is positive and one is negative – both have to have the same sign • An overflow can be detected if the carry into the sign bit position and the carry out of the sign bit position are not equal Example: 2/3/2023 Department of CSE (AI/ML) 20
  • 21. Decimal Fixed point representation • The representation of decimal numbers in registers is a function of the binary code used to represent a decimal digit • A 4-bit decimal code requires four flip-flops for each decimal digit. • This takes much more space than the equivalent binary representation and the circuits required to perform decimal arithmetic are more complex. • Representation of signed decimal numbers in BCD is similar to the representation of signed numbers in binary. • Either signed magnitude or signed complement systems . • The sign of a number is represented with four bits • 0000 for + • 1001 for – • To obtain the 10’s complement of a BCD number, first take the 9’s complement and then add one to the least significant digits 2/3/2023 Department of CSE (AI/ML) 21
  • 22. Example Example: (+375) + (-240) = +135 done in signed 10’s Complement System 2/3/2023 Department of CSE (AI/ML) 22
  • 23. Topics to be covered in next session 18 • Floating point representations 2/3/2023 Department of CSE (AI/ML) 23 Thank you!!!