SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmeticSanjay Saluth
 
Error Detection and Correction
Error Detection and CorrectionError Detection and Correction
Error Detection and CorrectionTechiNerd
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complementsarunachalamr16
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And CorrectionRenu Kewalramani
 
BINARY NUMBER SYSTEM
BINARY NUMBER SYSTEMBINARY NUMBER SYSTEM
BINARY NUMBER SYSTEMZaheer Abbasi
 
Binary Multiplication & Division.pptx
Binary Multiplication & Division.pptxBinary Multiplication & Division.pptx
Binary Multiplication & Division.pptxPooja Dixit
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...Arti Parab Academics
 
Introduction to binary number system
Introduction to binary number systemIntroduction to binary number system
Introduction to binary number systemVikas Dongre
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
Decimal to binary number
Decimal to binary numberDecimal to binary number
Decimal to binary numberguestd8696a
 
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
 
binary number system
 binary number system binary number system
binary number systemvishal gupta
 

La actualidad más candente (20)

2s complement arithmetic
2s complement arithmetic2s complement arithmetic
2s complement arithmetic
 
Error Detection and Correction
Error Detection and CorrectionError Detection and Correction
Error Detection and Correction
 
1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
 
2's complement
2's complement2's complement
2's complement
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Codes
CodesCodes
Codes
 
Number System
Number SystemNumber System
Number System
 
BINARY NUMBER SYSTEM
BINARY NUMBER SYSTEMBINARY NUMBER SYSTEM
BINARY NUMBER SYSTEM
 
Representation of Real Numbers
Representation of Real NumbersRepresentation of Real Numbers
Representation of Real Numbers
 
Arithmetic circuits
Arithmetic circuitsArithmetic circuits
Arithmetic circuits
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
Complements
ComplementsComplements
Complements
 
Binary Multiplication & Division.pptx
Binary Multiplication & Division.pptxBinary Multiplication & Division.pptx
Binary Multiplication & Division.pptx
 
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
FYBSC IT Digital Electronics Unit I Chapter II Number System and Binary Arith...
 
Introduction to binary number system
Introduction to binary number systemIntroduction to binary number system
Introduction to binary number system
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Decimal to binary number
Decimal to binary numberDecimal to binary number
Decimal to binary number
 
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
 
Data Representation
Data RepresentationData Representation
Data Representation
 
binary number system
 binary number system binary number system
binary number system
 

Destacado

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
 

Destacado (20)

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
 
Representation of Negative Numbers
Representation of Negative NumbersRepresentation of Negative Numbers
Representation of Negative Numbers
 
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
Binary arithmeticBinary arithmetic
Binary arithmetic
 
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)
 

Similar a Complement

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
 
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
 

Similar a Complement (20)

Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
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
 

Último

IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resourcesaileywriter
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17Celine George
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointELaRue0
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxnuriaiuzzolino1
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxCeline George
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPragya - UEM Kolkata Quiz Club
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptxmanishaJyala2
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfdm4ashexcelr
 

Último (20)

IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Mbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptxMbaye_Astou.Education Civica_Human Rights.pptx
Mbaye_Astou.Education Civica_Human Rights.pptx
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdf
 

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

Notas del editor

  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 ) .