SlideShare a Scribd company logo
1 of 10
One’s and Two’s Complement
Numbers and Arithmetic
Operations
1
Digital electronics
13IDP14
2
OutlineOutline
 Number of binary digits (bits) used in
computers for arithmetic operations
 Positive and negative number representation
using bits
 1’s complement and 2’s complement
 Arithmetic operations in 2’s complement
 Carry and overflow concepts
 See module 2a notes for more examples
Bits Used in Computers for
Numbers and Implications
 4, 8, 16, 32, 64
 Using 4 bits we can only represent 24
= 16
numbers -8, -7, -6, -5, …-1, 0, 1, … 7
 Using 8 bits we can only represent 28
= 256
numbers -128, -127, …-1, 0, 1, … 127
 Since we can represent only a fixed number of
positive and negative numbers, we may get
wrong results when we compute arithmetic
operations
 We must determine when the results are
wrong
One’s and Two’s Complement
0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000
+7 +6 +5 +4 +3 +2 +1 +0 -0 -1 -2 -3 -4 -5 -6 -7
Cryptography -Part -I 4
0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000
+7 +6 +5 +4 +3 +2 +1 +0 -1 -2 -3 -4 -5 -6 -7 -8
One’s Complement
Two’s Complement
Two’s Complement Number
Representation and Value (1)
 MSB represents negative number with a
value.
 Example: 8-bit number say
 1101 0011
 Value in decimal
 = -1*27
+ 1*26
+ 0*25
+ 1*24
+ 0*23
+0*22
+ 1*21
+ 1
 =-128 +64+0+16+0+0+2+1
 =-128+83
 =-45
Cryptography -Part -I 5
Two’s Complement Number
Representation and Value (2)
 Example: 1111 1111
 Decimal Value
 = -1*27
+ 1*26
+ 1*25
+ 1*24
+ 1*23
+1*22
+ 1*21
+ 1
 = -128+64+32+16+8+4+2+1 =-128+127 = -1
 Example: 1000 0000 Value = -128
 Example: 0111 1111 Value = 127
Cryptography -Part -I 6
Finding a Negative of a number
 Assume 1’s complement
 Number 8-bit: 0000 1111; value =15
 Given 15 determine -15
 Change all 0 to 1 and 1 to zero
 Result: 1111 0000 = -127+64+32+16 =-127+112 = -15
 Assume 2’s complement
 Number 8-bit: 0000 1111; value =15
 Given 15 determine -15
 Change all 0 to 1 and 1 to zero then add 1
 Result: 1111 0001 = -128+64+32+16+1 =-128+113 = -15
7
Arithmetic Operations in Two’s
Complement (1)
 Example:Find 7 – 5 assuming 4-bit numbers
7 = 0111 ; -5 =1011 in 2’s complement
0111
1011
-----
10010
Carry in MSB 1, Carry out in MSB 1
Result ok value 2
Arithmetic Operations in Two’s
Complement (2)
 Example:Find 7 + 5 assuming 4-bit numbers
7 = 0111 ; 5 =0101 in 2’s complement
0111
0101
-----
1100
Carry in MSB 1, Carry out in MSB 0
Result wrong; value -4. We can not represent
real value 12. This is overflow.
9
Arithmetic Operations in Two’s
Complement (2)
 Example:Find 7 + 5 assuming 4-bit numbers
7 = 0111 ; 5 =0101 in 2’s complement
0111
0101
-----
1100
Carry in MSB 1, Carry out in MSB 0
Result wrong; value -4. We can not represent
real value 12. This is overflow.
9

More Related Content

What's hot

Number System (Binary,octal,Decimal,Hexadecimal)
Number System (Binary,octal,Decimal,Hexadecimal)Number System (Binary,octal,Decimal,Hexadecimal)
Number System (Binary,octal,Decimal,Hexadecimal)Lovely Singh
 
Approximation and error
Approximation and errorApproximation and error
Approximation and errorrubenarismendi
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationRitu Ranjan Shrivastwa
 
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etcBOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etcAbhishek Rajpoot
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesDr. Anita Goel
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)cs19club
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursionAbdullah Al-hazmy
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
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
 
Newton's forward & backward interpolation
Newton's forward & backward interpolationNewton's forward & backward interpolation
Newton's forward & backward interpolationHarshad Koshti
 
binary number system
 binary number system binary number system
binary number systemvishal gupta
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adderdragonpradeep
 
Error Finding in Numerical method
Error Finding in Numerical methodError Finding in Numerical method
Error Finding in Numerical methodFazle Rabbi Ador
 

What's hot (20)

Representation of Negative Numbers
Representation of Negative NumbersRepresentation of Negative Numbers
Representation of Negative Numbers
 
Number System (Binary,octal,Decimal,Hexadecimal)
Number System (Binary,octal,Decimal,Hexadecimal)Number System (Binary,octal,Decimal,Hexadecimal)
Number System (Binary,octal,Decimal,Hexadecimal)
 
Approximation and error
Approximation and errorApproximation and error
Approximation and error
 
Complements
ComplementsComplements
Complements
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Binary true ppt
Binary true pptBinary true ppt
Binary true ppt
 
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etcBOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
BOOTH ALGO, DIVISION(RESTORING _ NON RESTORING) etc etc
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
BCD ADDER
BCD ADDER BCD ADDER
BCD ADDER
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Data Structures- Part5 recursion
Data Structures- Part5 recursionData Structures- Part5 recursion
Data Structures- Part5 recursion
 
BCD Adder
BCD AdderBCD Adder
BCD Adder
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
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
 
Newton's forward & backward interpolation
Newton's forward & backward interpolationNewton's forward & backward interpolation
Newton's forward & backward interpolation
 
binary number system
 binary number system binary number system
binary number system
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adder
 
Error Finding in Numerical method
Error Finding in Numerical methodError Finding in Numerical method
Error Finding in Numerical method
 

Viewers also liked

2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmeticSanjay Saluth
 
Math1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's ComplementMath1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's Complementgcmath1003
 
Math1003 - An Intro to Number Systems
Math1003 - An Intro to Number SystemsMath1003 - An Intro to Number Systems
Math1003 - An Intro to Number Systemsgcmath1003
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversionkanyuma jitjumnong
 
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)Vitthal Jadhav
 
Operating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsOperating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsPeter Tröger
 
Analog and digital signal system : digital logic
Analog and digital signal system : digital logicAnalog and digital signal system : digital logic
Analog and digital signal system : digital logicSatya P. Joshi
 
Thread presentation
Thread presentationThread presentation
Thread presentationAAshish Ojha
 
Binary Arithmetic Presentation about Binary Numbers 2015
Binary Arithmetic Presentation about Binary Numbers 2015Binary Arithmetic Presentation about Binary Numbers 2015
Binary Arithmetic Presentation about Binary Numbers 2015An Ariyan
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rulesstudent
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ahmar Hashmi
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingguesta40f80
 

Viewers also liked (20)

2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
 
Math1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's ComplementMath1003 1.15 - Integers and 2's Complement
Math1003 1.15 - Integers and 2's Complement
 
Math1003 - An Intro to Number Systems
Math1003 - An Intro to Number SystemsMath1003 - An Intro to Number Systems
Math1003 - An Intro to Number Systems
 
Introduction number systems and conversion
 Introduction number systems and conversion Introduction number systems and conversion
Introduction number systems and conversion
 
Number System
Number SystemNumber System
Number System
 
Digital logic mohammed salim ch3
Digital logic mohammed salim ch3Digital logic mohammed salim ch3
Digital logic mohammed salim ch3
 
Digital logic mohammed salim ch2
Digital logic mohammed salim ch2Digital logic mohammed salim ch2
Digital logic mohammed salim ch2
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)Ranjak Vaidic Ganit Preview (Marathi Research Book)
Ranjak Vaidic Ganit Preview (Marathi Research Book)
 
DLD Intro
DLD IntroDLD Intro
DLD Intro
 
Main Memory
Main MemoryMain Memory
Main Memory
 
OS - Thread
OS - ThreadOS - Thread
OS - Thread
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 
Operating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - ThreadsOperating Systems 1 (7/12) - Threads
Operating Systems 1 (7/12) - Threads
 
Analog and digital signal system : digital logic
Analog and digital signal system : digital logicAnalog and digital signal system : digital logic
Analog and digital signal system : digital logic
 
Thread presentation
Thread presentationThread presentation
Thread presentation
 
Binary Arithmetic Presentation about Binary Numbers 2015
Binary Arithmetic Presentation about Binary Numbers 2015Binary Arithmetic Presentation about Binary Numbers 2015
Binary Arithmetic Presentation about Binary Numbers 2015
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rules
 
Ch5: Threads (Operating System)
Ch5: Threads (Operating System)Ch5: Threads (Operating System)
Ch5: Threads (Operating System)
 
Operating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programmingOperating System Chapter 4 Multithreaded programming
Operating System Chapter 4 Multithreaded programming
 

Similar to Complement

Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilanganahmad haidaroh
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxRameshK531901
 
Video lectures
Video lecturesVideo lectures
Video lecturesEdhole.com
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.pptSathishkumar.V
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.pptMeghadriGhosh4
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides pptnashitahalwaz95
 
Chapter 2 Data Representation on CPU (part 1)
Chapter 2 Data Representation on CPU (part 1)Chapter 2 Data Representation on CPU (part 1)
Chapter 2 Data Representation on CPU (part 1)Frankie Jones
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.pptssuser52a19e
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalUtkirjonUbaydullaev1
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.pptRAJKUMARP63
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemISMT College
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 

Similar to Complement (20)

Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 
Alu1
Alu1Alu1
Alu1
 
digital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptxdigital-systems-and-binary-numbers1.pptx
digital-systems-and-binary-numbers1.pptx
 
Video lectures
Video lecturesVideo lectures
Video lectures
 
Mba ebooks
Mba ebooksMba ebooks
Mba ebooks
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
 
2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt2sComplementArithmetic1.ppt
2sComplementArithmetic1.ppt
 
2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt2sComplementArithmetic1 lecture slides ppt
2sComplementArithmetic1 lecture slides ppt
 
Chapter 2 Data Representation on CPU (part 1)
Chapter 2 Data Representation on CPU (part 1)Chapter 2 Data Representation on CPU (part 1)
Chapter 2 Data Representation on CPU (part 1)
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Okkkkk
OkkkkkOkkkkk
Okkkkk
 
Number_Systems (2).ppt
Number_Systems (2).pptNumber_Systems (2).ppt
Number_Systems (2).ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
binary-numbers.ppt
 
Review on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and HexadecimalReview on Number Systems: Decimal, Binary, and Hexadecimal
Review on Number Systems: Decimal, Binary, and Hexadecimal
 
ch3a-binary-numbers.ppt
ch3a-binary-numbers.pptch3a-binary-numbers.ppt
ch3a-binary-numbers.ppt
 
Chapter 2.1 introduction to number system
Chapter 2.1 introduction to number systemChapter 2.1 introduction to number system
Chapter 2.1 introduction to number system
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 

Recently uploaded

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Complement

  • 1. One’s and Two’s Complement Numbers and Arithmetic Operations 1 Digital electronics 13IDP14
  • 2. 2 OutlineOutline  Number of binary digits (bits) used in computers for arithmetic operations  Positive and negative number representation using bits  1’s complement and 2’s complement  Arithmetic operations in 2’s complement  Carry and overflow concepts  See module 2a notes for more examples
  • 3. Bits Used in Computers for Numbers and Implications  4, 8, 16, 32, 64  Using 4 bits we can only represent 24 = 16 numbers -8, -7, -6, -5, …-1, 0, 1, … 7  Using 8 bits we can only represent 28 = 256 numbers -128, -127, …-1, 0, 1, … 127  Since we can represent only a fixed number of positive and negative numbers, we may get wrong results when we compute arithmetic operations  We must determine when the results are wrong
  • 4. One’s and Two’s Complement 0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000 +7 +6 +5 +4 +3 +2 +1 +0 -0 -1 -2 -3 -4 -5 -6 -7 Cryptography -Part -I 4 0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000 +7 +6 +5 +4 +3 +2 +1 +0 -1 -2 -3 -4 -5 -6 -7 -8 One’s Complement Two’s Complement
  • 5. Two’s Complement Number Representation and Value (1)  MSB represents negative number with a value.  Example: 8-bit number say  1101 0011  Value in decimal  = -1*27 + 1*26 + 0*25 + 1*24 + 0*23 +0*22 + 1*21 + 1  =-128 +64+0+16+0+0+2+1  =-128+83  =-45 Cryptography -Part -I 5
  • 6. Two’s Complement Number Representation and Value (2)  Example: 1111 1111  Decimal Value  = -1*27 + 1*26 + 1*25 + 1*24 + 1*23 +1*22 + 1*21 + 1  = -128+64+32+16+8+4+2+1 =-128+127 = -1  Example: 1000 0000 Value = -128  Example: 0111 1111 Value = 127 Cryptography -Part -I 6
  • 7. Finding a Negative of a number  Assume 1’s complement  Number 8-bit: 0000 1111; value =15  Given 15 determine -15  Change all 0 to 1 and 1 to zero  Result: 1111 0000 = -127+64+32+16 =-127+112 = -15  Assume 2’s complement  Number 8-bit: 0000 1111; value =15  Given 15 determine -15  Change all 0 to 1 and 1 to zero then add 1  Result: 1111 0001 = -128+64+32+16+1 =-128+113 = -15 7
  • 8. Arithmetic Operations in Two’s Complement (1)  Example:Find 7 – 5 assuming 4-bit numbers 7 = 0111 ; -5 =1011 in 2’s complement 0111 1011 ----- 10010 Carry in MSB 1, Carry out in MSB 1 Result ok value 2
  • 9. Arithmetic Operations in Two’s Complement (2)  Example:Find 7 + 5 assuming 4-bit numbers 7 = 0111 ; 5 =0101 in 2’s complement 0111 0101 ----- 1100 Carry in MSB 1, Carry out in MSB 0 Result wrong; value -4. We can not represent real value 12. This is overflow. 9
  • 10. Arithmetic Operations in Two’s Complement (2)  Example:Find 7 + 5 assuming 4-bit numbers 7 = 0111 ; 5 =0101 in 2’s complement 0111 0101 ----- 1100 Carry in MSB 1, Carry out in MSB 0 Result wrong; value -4. We can not represent real value 12. This is overflow. 9

Editor's Notes

  1. Given any positive integer n and any nonnegative integer a, if we divide a by n, we get an integer quotient q and an integer remainder r. In modular arithmetic we are only interested in the remainder (or residue) after division by some modulus, and results with the same remainder are regarded as equivalent. Two integers a and b are said to be congruent modulo n, if (a mod n ) = ( b mod n ) .