SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complementsarunachalamr16
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
EC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementEC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementAmberSinghal1
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representationMaskurAlShalSabil
 
Circular linked list
Circular linked listCircular linked list
Circular linked listchauhankapil
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adderGaditek
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rulesstudent
 
Array operations
Array operationsArray operations
Array operationsZAFAR444
 
Chapter 4. logic function and boolean algebra
Chapter 4. logic function and boolean algebraChapter 4. logic function and boolean algebra
Chapter 4. logic function and boolean algebraAshish KC
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual Shankar Gangaju
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital ElectronicsJanki Shah
 

Tendances (20)

1’s and 2’s complements
1’s and 2’s complements1’s and 2’s complements
1’s and 2’s complements
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Boolean Algebra
Boolean AlgebraBoolean Algebra
Boolean Algebra
 
EC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's ComplementEC Binary Substraction using 1's Complement,2's Complement
EC Binary Substraction using 1's Complement,2's Complement
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representation
 
Infix to postfix conversion
Infix to postfix conversionInfix to postfix conversion
Infix to postfix conversion
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
2's complement
2's complement2's complement
2's complement
 
Representation of Negative Numbers
Representation of Negative NumbersRepresentation of Negative Numbers
Representation of Negative Numbers
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adder
 
Complements
ComplementsComplements
Complements
 
Bcd
BcdBcd
Bcd
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
binary arithmetic rules
binary arithmetic rulesbinary arithmetic rules
binary arithmetic rules
 
Array operations
Array operationsArray operations
Array operations
 
Chapter 4. logic function and boolean algebra
Chapter 4. logic function and boolean algebraChapter 4. logic function and boolean algebra
Chapter 4. logic function and boolean algebra
 
BINARY SUBTRACTION
BINARY SUBTRACTIONBINARY SUBTRACTION
BINARY SUBTRACTION
 
Computer organization and architecture lab manual
Computer organization and architecture lab manual Computer organization and architecture lab manual
Computer organization and architecture lab manual
 
Number system in Digital Electronics
Number system in Digital ElectronicsNumber system in Digital Electronics
Number system in Digital Electronics
 

En vedette

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

En vedette (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
Binary arithmeticBinary arithmetic
Binary arithmetic
 
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
 

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

Similaire à 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
 
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
 
binary-numbers.ppt
binary-numbers.pptbinary-numbers.ppt
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
 

Dernier

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 

Dernier (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 

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

Notes de l'éditeur

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