SlideShare a Scribd company logo
1 of 36
Binary Operations
Math/Logical
Binary Math
Decimal Addition Example
3 7 5 8
+ 4 6 5 7
1) Add 8 + 7 = 15
Write down 5, carry 1
1
8
1 1
4 1 5 4) Add 3 + 4 + 1 = 8
Write down 8
3) Add 7 + 6 + 1 = 14
Write down 4, carry 1
2) Add 5 + 5 + 1 = 11
Write down 1, carry 1
Add 3758 to 4657:
Decimal Addition Explanation
1 1 1
3 7 5 8
+ 4 6 5 7
8 4 1 5
What just happened?
1 1 1 (carry)
3 7 5 8
+ 4 6 5 7
8 14 11 15 (sum)
- 10 10 10 (subtract the base)
8 4 1 5
So when the sum of a column is equal to or greater than
the base, we subtract the base from the sum, record the
difference, and carry one to the next column to the left.
Binary Addition Rules
Rules:
 0 + 0 = 0
 0 + 1 = 1
 1 + 0 = 1 (just like in decimal)
 1 + 1 = 210
= 102 = 0 with 1 to carry
 1 + 1 + 1 = 310
= 112 = 1 with 1 to carry
Binary Addition Example 1
1 1 0 1 1 1
+ 0 1 1 1 0 0
1
1
111
0 1 0 0 11
Example 1: Add
binary 110111 to 11100
Col 1) Add 1 + 0 = 1
Write 1
Col 2) Add 1 + 0 = 1
Write 1
Col 3) Add 1 + 1 = 2 (10 in binary)
Write 0, carry 1
Col 4) Add 1+ 0 + 1 = 2
Write 0, carry 1
Col 6) Add 1 + 1 + 0 = 2
Write 0, carry 1
Col 5) Add 1 + 1 + 1 = 3 (11 in binary)
Write 1, carry 1
Col 7) Bring down the carried 1
Write 1
Binary Addition Explanation
1 1 0 1 1 1
+ 0 1 1 1 0 0
- .
1
1
111
0 1 0 0 11
In the first two columns,
there were no carries.
In column 3, we add 1 + 1 = 2
Since 2 is equal to the base, subtract
the base from the sum and carry 1.
In column 4, we also subtract
the base from the sum and carry 1.
In column 6, we also subtract
the base from the sum and carry 1.
In column 5, we also subtract
the base from the sum and carry 1.
In column 7, we just bring down the
carried 1
2
2 2 23
222
What is actually
happened when we
carried in binary?
Binary Addition Verification
Verification
1101112  5510
+0111002 + 2810
8310
64 32 16 8 4 2 1
1 0 1 0 0 1 1
= 64 + 16 + 2 +1
= 8310
1 1 0 1 1 1
+ 0 1 1 1 0 0
1 0 1 0 0 11
You can always check your
answer by converting the
figures to decimal, doing the
addition, and comparing the
answers.
Binary Addition Example 2
Verification
1110102  5810
+0011112 + 1510
7310
64 32 16 8 4 2 1
1 0 0 1 0 0 1
= 64 + 8 +1
= 7310
1 1 1 0 1 0
+ 0 0 1 1 1 1
1
1
11
0 0 1 0 10
Example 2:
Add 1111 to 111010.
11
Decimal Subtraction
Example
8 0 2 5
- 4 6 5 7
Subtract
4657 from 8025:
7 9 11
11
8633
1) Try to subtract 5 – 7  can’t.
Must borrow 10 from next column.
4) Subtract 7 – 4 = 3
3) Subtract 9 – 6 = 3
2) Try to subtract 1 – 5  can’t.
Must borrow 10 from next column.
But next column is 0, so must go to
column after next to borrow.
Add the borrowed 10 to the original 0.
Now you can borrow 10 from this column.
Add the borrowed 10 to the original 5.
Then subtract 15 – 7 = 8.
Add the borrowed 10 to the original 1..
Then subract 11 – 5 = 6
Decimal Subtraction
Explanation
So when you cannot subtract, you borrow from the
column to the left.
The amount borrowed is 1 base unit,
which in decimal is 10.
The 10 is added to the original column value,
so you will be able to subtract.
8633
8 0 2 5
- 4 6 5 7
Binary Subtraction
Explanation
 In binary, the base unit is 2
 So when you cannot subtract, you borrow from the
column to the left.
 The amount borrowed is 2.
 The 2 is added to the original column value, so
you will be able to subtract.
Binary Subtraction
Example 1
1 1 0 0 1 1
- 1 1 1 0 0
Example 1: Subtract
binary 11100 from 110011
2
0 0 2
1
2
1101
Col 1) Subtract 1 – 0 = 1
Col 5) Try to subtract 0 – 1  can’t.
Must borrow from next column.
Col 4) Subtract 1 – 1 = 0
Col 3) Try to subtract 0 – 1  can’t.
Must borrow 2 from next column.
But next column is 0, so must go to
column after next to borrow.
Add the borrowed 2 to the 0 on the right.
Now you can borrow from this column
(leaving 1 remaining).
Col 2) Subtract 1 – 0 = 1
Add the borrowed 2 to the original 0.
Then subtract 2 – 1 = 1
1
Add the borrowed 2 to the remaining 0.
Then subtract 2 – 1 = 1
Col 6) Remaining leading 0 can be ignored.
Binary Subtraction
Verification
Verification
1100112  5110
- 111002 - 2810
2310
64 32 16 8 4 2 1
1 0 1 1 1
= 16 + 4 + 2 + 1
= 2310
1 1 0 0 1 1
- 1 1 1 0 0
2
0 0 2
1
2
1101 1
Subtract binary
11100 from 110011:
Binary Subtraction
Example 2
1 0 1 0 0 1
- 1 0 1 0 0
Example 2: Subtract
binary 10100 from 101001
20 0 2
1101 0
Verification
1010012  4110
- 101002 - 2010
2110
64 32 16 8 4 2 1
1 0 1 0 1
= 16 + 4 + 1
= 2110
Logical, Shift, and Rotate
Operations
Logical, Shift and Rotate
Operations
 A particular bit, or set of bits, within the byte can be set to
1 or 0, depending on conditions encountered during the
execution of a program.
 When so used, these bits are often called "flags".
 Frequently, the programmer must manipulate these
individual bits - an activity sometimes known as "bit
twiddling".
 The logical, shift, and rotate operations provide the
means for manipulating the bits.
Logical OR Rules
OR Operations
 OR Results in 1 if either or both of the
operands are 1.
 OR Table
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1
Logical OR Operation
To perform the OR operation, take one
column at a time and perform the OR
operation using the OR table.
Ex 1: 1 0 0 1 0 0 1 1
OR 0 0 0 0 1 1 1 1
1 0 0 1 1 1 1 1
Logical OR Examples
Ex 3: 0 1 1 1
OR 0 0 1 0
0 1 1 1
Ex 2: 1 1 0 0 1 0 0 1
OR 0 0 0 0 1 0 1 0
1 1 0 0 1 0 1 1
Logical XOR Rules
XOR Operations
 The exclusive OR. Similar to OR except that
it now gives 0 when both its operands are 1.
Rules.
0 XOR 0 = 0
0 XOR 1 = 1
1 XOR 0 = 1
1 XOR 1 = 0
Logical XOR Examples
Ex 1: 1 0 0 1 1 0 0 1
XOR 0 0 0 0 1 1 1 1
1 0 0 1 0 1 1 0
Ex 2: 0 1 1 1
XOR 0 0 1 0
0 1 0 1
Logical AND Rules
AND Operations
 AND yields 1 only if both its operands are 1.
Rules.
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
Logical AND Examples
 Ex 1: 1 1 0 1 0 0 1 1
AND 0 0 0 0 1 1 1 1
0 0 0 0 0 0 1 1
 Ex 2: 0 1 1 1
AND 1 0 0 1
0 0 0 1
Logical NOT
NOT Operations
 NOT is a separate operator for flipping the bits.
Rules.
NOT 0 = 1
NOT 1 = 0
Example. NOT 1 0 1 0 = 0 1 0 1
Shift and Rotate operations
Whereas logical operations allow the
changing of bit values in place,
SHIFT and ROTATE operations allow bits
to be moved left or right without
changing their values.
Shift Left operation
 SHL
SHL (shift left) shifts each bit one place to the left.
The original leftmost bit is lost and a 0 is shifted into
the rightmost position.
Ex 1. SHL 1 1 0 1
Ex 2. SHL 1 1 0 0
= 1 0 0 0
01 1 0 11 1 0 1 = 1 0 1 0
Shift Left - Multiple Bits
 SHL # bits means to shift left # times
Ex 1: SHL 3 1 0 0 1 1 1 0 0
Ex 2: SHL 2 1 1 1 0 0 1 1 0
= 1 0 0 1 1 0 0 0
1 0 0 1 1 1 0 01 0 0 1 1 1 0 0 0 0 0 = 1 1 1 0 0 0 0 0
Shift Right operation
SHR
SHR (shift right) shifts each bit one place to
the right. The original rightmost bit is lost and
a 0 is shifted into the leftmost position.
Ex 1. SHR 1 0 1 1
Ex 2. SHR 0 0 1 1
= 0 0 0 1
0 1 0 1 1 = 0 1 0 1
Shift Right – Multiple Bits
 SHR # bits means to shift right # times
Ex 1: SHR 3 1 0 0 1 1 1 0 0
0 0 0 1 0 0 1 1 1 0 0 = 0 0 0 1 0 0 1 1
Ex 2: SHR 2 1 1 1 0 0 1 1 0
= 0 0 1 1 1 0 0 1
Arithmetic Shift Right
operation
ASR (retains rightmost sign bit)
Shifts each bit one place to the right. The original
rightmost bit is lost and a the value of the most significant
bit (leftmost bit) is shifted into the new leftmost position.
Ex 1. ASR 1 0 1 1
Ex 2. ASR 0 0 1 1
= 0 0 0 1
1 1 0 1 1 = 1 1 0 1
Arithmetic Shift Right –
Multiple Bits
 ASR # bits means to arithmetic shift right # times
Ex 1: ASR 3 1 0 0 1 1 1 0 0
1 1 1 1 0 0 1 1 1 0 0 = 1 1 1 1 0 0 1 1
Ex 2: ASR 2 0 1 1 0 0 1 1 0
= 0 0 0 1 1 0 0 1
Rotate Left operation
 ROL
ROL (rotate left) shifts each bit one place to the left.
The original leftmost bit is shifted into the rightmost
position. No bits are lost.
Ex 1. ROL 1 1 0 1
Ex 2. ROL 1 1 0 0
= 1 0 0 1
1 0 1 1
Rotate Left – Multiple Bits
 ROL # bits means to rotate left # times
Ex 1: ROL 3 1 0 0 1 1 1 0 0
= 1 1 1 0 0 1 0 0
Ex 2: ROL 2 1 1 1 0 0 1 1 0
= 1 0 0 1 1 0 1 1
Rotate Right operation
 ROR
ROR (rotate right) shifts each bit one place to the right.
The original rightmost bit is shifted into the leftmost
position. No bits are lost.
Ex 1. ROR 1 0 1 1
  Ex 2. ROR 0 0 1 1
= 1 0 0 1
1 0 11
Rotate Right – Multiple Bits
 ROR # bits means to rotate right # times
Ex 1: ROR 3 1 0 0 1 1 1 0 0
= 1 0 0 1 0 0 1 1
Ex 2: ROR 2 1 1 1 0 0 1 1 0
= 1 0 1 1 1 0 0 1

More Related Content

What's hot

Adding Subtracting Integers
Adding Subtracting IntegersAdding Subtracting Integers
Adding Subtracting IntegersMr. M
 
Fraction To Decimal
Fraction To DecimalFraction To Decimal
Fraction To DecimalDonna Furrey
 
Integers ppt
Integers pptIntegers ppt
Integers pptAndrea B.
 
ppt for Properties of the Operations on Integers
ppt for Properties of the Operations on Integersppt for Properties of the Operations on Integers
ppt for Properties of the Operations on Integersneria_ayren
 
Scientific Notation
Scientific NotationScientific Notation
Scientific NotationAwais Khan
 
lesson plan on Addition & subtraction of integers
lesson plan on Addition & subtraction of integerslesson plan on Addition & subtraction of integers
lesson plan on Addition & subtraction of integersCheryl Asia
 
Operations with rational numbers
Operations with rational numbersOperations with rational numbers
Operations with rational numbersKelly Scallion
 
Add & subtract mixed numbers
Add & subtract mixed numbersAdd & subtract mixed numbers
Add & subtract mixed numbersangelwatler
 
PEMDAS - The Proper Order of Mathematical Operations
PEMDAS - The Proper Order of Mathematical OperationsPEMDAS - The Proper Order of Mathematical Operations
PEMDAS - The Proper Order of Mathematical OperationsMark (Mong) Montances
 
Powerpoint on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...
Powerpoint  on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...Powerpoint  on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...
Powerpoint on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...Franz Jeremiah Ü Ibay
 
mutually-exclusive-events.ppt
mutually-exclusive-events.pptmutually-exclusive-events.ppt
mutually-exclusive-events.pptJosephSPalileoJr
 
Chapter 1 Study Guide
Chapter 1  Study  GuideChapter 1  Study  Guide
Chapter 1 Study Guide♥Moriah♥
 
Dividing polynomials
Dividing polynomialsDividing polynomials
Dividing polynomialssalvie alvaro
 
Multiplying Polynomials: Two Binomials
Multiplying Polynomials: Two BinomialsMultiplying Polynomials: Two Binomials
Multiplying Polynomials: Two BinomialsJoey Valdriz
 
Factors on difference of two squares
Factors on difference of two squaresFactors on difference of two squares
Factors on difference of two squaresLorie Jane Letada
 
Converting fraction into decimals and vice versa(MAth 7)
Converting fraction into decimals and vice versa(MAth 7)Converting fraction into decimals and vice versa(MAth 7)
Converting fraction into decimals and vice versa(MAth 7)Carlo Arabit
 
Properties of logarithms
Properties of logarithmsProperties of logarithms
Properties of logarithmsJessica Garcia
 

What's hot (20)

Adding Subtracting Integers
Adding Subtracting IntegersAdding Subtracting Integers
Adding Subtracting Integers
 
Fraction To Decimal
Fraction To DecimalFraction To Decimal
Fraction To Decimal
 
Integers ppt
Integers pptIntegers ppt
Integers ppt
 
ppt for Properties of the Operations on Integers
ppt for Properties of the Operations on Integersppt for Properties of the Operations on Integers
ppt for Properties of the Operations on Integers
 
Scientific Notation
Scientific NotationScientific Notation
Scientific Notation
 
lesson plan on Addition & subtraction of integers
lesson plan on Addition & subtraction of integerslesson plan on Addition & subtraction of integers
lesson plan on Addition & subtraction of integers
 
Operations with rational numbers
Operations with rational numbersOperations with rational numbers
Operations with rational numbers
 
Add & subtract mixed numbers
Add & subtract mixed numbersAdd & subtract mixed numbers
Add & subtract mixed numbers
 
PEMDAS - The Proper Order of Mathematical Operations
PEMDAS - The Proper Order of Mathematical OperationsPEMDAS - The Proper Order of Mathematical Operations
PEMDAS - The Proper Order of Mathematical Operations
 
Division Of Polynomials
Division Of PolynomialsDivision Of Polynomials
Division Of Polynomials
 
Powerpoint on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...
Powerpoint  on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...Powerpoint  on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...
Powerpoint on K-12 Mathematics Grade 7 Q1 (Fundamental Operations of Integer...
 
mutually-exclusive-events.ppt
mutually-exclusive-events.pptmutually-exclusive-events.ppt
mutually-exclusive-events.ppt
 
Chapter 1 Study Guide
Chapter 1  Study  GuideChapter 1  Study  Guide
Chapter 1 Study Guide
 
Inverse functions
Inverse functionsInverse functions
Inverse functions
 
Dividing polynomials
Dividing polynomialsDividing polynomials
Dividing polynomials
 
Multiplying Polynomials: Two Binomials
Multiplying Polynomials: Two BinomialsMultiplying Polynomials: Two Binomials
Multiplying Polynomials: Two Binomials
 
Factors on difference of two squares
Factors on difference of two squaresFactors on difference of two squares
Factors on difference of two squares
 
Real Number System
Real Number SystemReal Number System
Real Number System
 
Converting fraction into decimals and vice versa(MAth 7)
Converting fraction into decimals and vice versa(MAth 7)Converting fraction into decimals and vice versa(MAth 7)
Converting fraction into decimals and vice versa(MAth 7)
 
Properties of logarithms
Properties of logarithmsProperties of logarithms
Properties of logarithms
 

Similar to Binary operations

Binary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwBinary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwJoji Thompson
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
09 binary number systems
09   binary number systems09   binary number systems
09 binary number systemsLee Chadwick
 
Ncp computer appls num sys1 pramod
Ncp computer appls  num sys1 pramodNcp computer appls  num sys1 pramod
Ncp computer appls num sys1 pramodNCP
 
Binary octal
Binary octalBinary octal
Binary octaldrdipo4
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer ArchitectureRavi Kumar
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer ArchitectureRavi Kumar
 
Convertion of single precision
Convertion of single precisionConvertion of single precision
Convertion of single precisionnikhilarora2211
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncrEdhole.com
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncrEdhole.com
 

Similar to Binary operations (20)

Binary Mathematics Classwork and Hw
Binary Mathematics Classwork and HwBinary Mathematics Classwork and Hw
Binary Mathematics Classwork and Hw
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
09 binary number systems
09   binary number systems09   binary number systems
09 binary number systems
 
Binary
BinaryBinary
Binary
 
Ncp computer appls num sys1 pramod
Ncp computer appls  num sys1 pramodNcp computer appls  num sys1 pramod
Ncp computer appls num sys1 pramod
 
Binary octal
Binary octalBinary octal
Binary octal
 
2's complement
2's complement2's complement
2's complement
 
Booth Multiplier
Booth MultiplierBooth Multiplier
Booth Multiplier
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Number system
Number systemNumber system
Number system
 
Alu1
Alu1Alu1
Alu1
 
Convertion of single precision
Convertion of single precisionConvertion of single precision
Convertion of single precision
 
NUMBER BASE SYSTEM.pptx
NUMBER BASE SYSTEM.pptxNUMBER BASE SYSTEM.pptx
NUMBER BASE SYSTEM.pptx
 
CA Unit ii
CA Unit iiCA Unit ii
CA Unit ii
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 

Recently uploaded

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 

Recently uploaded (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

Binary operations

  • 3. Decimal Addition Example 3 7 5 8 + 4 6 5 7 1) Add 8 + 7 = 15 Write down 5, carry 1 1 8 1 1 4 1 5 4) Add 3 + 4 + 1 = 8 Write down 8 3) Add 7 + 6 + 1 = 14 Write down 4, carry 1 2) Add 5 + 5 + 1 = 11 Write down 1, carry 1 Add 3758 to 4657:
  • 4. Decimal Addition Explanation 1 1 1 3 7 5 8 + 4 6 5 7 8 4 1 5 What just happened? 1 1 1 (carry) 3 7 5 8 + 4 6 5 7 8 14 11 15 (sum) - 10 10 10 (subtract the base) 8 4 1 5 So when the sum of a column is equal to or greater than the base, we subtract the base from the sum, record the difference, and carry one to the next column to the left.
  • 5. Binary Addition Rules Rules:  0 + 0 = 0  0 + 1 = 1  1 + 0 = 1 (just like in decimal)  1 + 1 = 210 = 102 = 0 with 1 to carry  1 + 1 + 1 = 310 = 112 = 1 with 1 to carry
  • 6. Binary Addition Example 1 1 1 0 1 1 1 + 0 1 1 1 0 0 1 1 111 0 1 0 0 11 Example 1: Add binary 110111 to 11100 Col 1) Add 1 + 0 = 1 Write 1 Col 2) Add 1 + 0 = 1 Write 1 Col 3) Add 1 + 1 = 2 (10 in binary) Write 0, carry 1 Col 4) Add 1+ 0 + 1 = 2 Write 0, carry 1 Col 6) Add 1 + 1 + 0 = 2 Write 0, carry 1 Col 5) Add 1 + 1 + 1 = 3 (11 in binary) Write 1, carry 1 Col 7) Bring down the carried 1 Write 1
  • 7. Binary Addition Explanation 1 1 0 1 1 1 + 0 1 1 1 0 0 - . 1 1 111 0 1 0 0 11 In the first two columns, there were no carries. In column 3, we add 1 + 1 = 2 Since 2 is equal to the base, subtract the base from the sum and carry 1. In column 4, we also subtract the base from the sum and carry 1. In column 6, we also subtract the base from the sum and carry 1. In column 5, we also subtract the base from the sum and carry 1. In column 7, we just bring down the carried 1 2 2 2 23 222 What is actually happened when we carried in binary?
  • 8. Binary Addition Verification Verification 1101112  5510 +0111002 + 2810 8310 64 32 16 8 4 2 1 1 0 1 0 0 1 1 = 64 + 16 + 2 +1 = 8310 1 1 0 1 1 1 + 0 1 1 1 0 0 1 0 1 0 0 11 You can always check your answer by converting the figures to decimal, doing the addition, and comparing the answers.
  • 9. Binary Addition Example 2 Verification 1110102  5810 +0011112 + 1510 7310 64 32 16 8 4 2 1 1 0 0 1 0 0 1 = 64 + 8 +1 = 7310 1 1 1 0 1 0 + 0 0 1 1 1 1 1 1 11 0 0 1 0 10 Example 2: Add 1111 to 111010. 11
  • 10. Decimal Subtraction Example 8 0 2 5 - 4 6 5 7 Subtract 4657 from 8025: 7 9 11 11 8633 1) Try to subtract 5 – 7  can’t. Must borrow 10 from next column. 4) Subtract 7 – 4 = 3 3) Subtract 9 – 6 = 3 2) Try to subtract 1 – 5  can’t. Must borrow 10 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 10 to the original 0. Now you can borrow 10 from this column. Add the borrowed 10 to the original 5. Then subtract 15 – 7 = 8. Add the borrowed 10 to the original 1.. Then subract 11 – 5 = 6
  • 11. Decimal Subtraction Explanation So when you cannot subtract, you borrow from the column to the left. The amount borrowed is 1 base unit, which in decimal is 10. The 10 is added to the original column value, so you will be able to subtract. 8633 8 0 2 5 - 4 6 5 7
  • 12. Binary Subtraction Explanation  In binary, the base unit is 2  So when you cannot subtract, you borrow from the column to the left.  The amount borrowed is 2.  The 2 is added to the original column value, so you will be able to subtract.
  • 13. Binary Subtraction Example 1 1 1 0 0 1 1 - 1 1 1 0 0 Example 1: Subtract binary 11100 from 110011 2 0 0 2 1 2 1101 Col 1) Subtract 1 – 0 = 1 Col 5) Try to subtract 0 – 1  can’t. Must borrow from next column. Col 4) Subtract 1 – 1 = 0 Col 3) Try to subtract 0 – 1  can’t. Must borrow 2 from next column. But next column is 0, so must go to column after next to borrow. Add the borrowed 2 to the 0 on the right. Now you can borrow from this column (leaving 1 remaining). Col 2) Subtract 1 – 0 = 1 Add the borrowed 2 to the original 0. Then subtract 2 – 1 = 1 1 Add the borrowed 2 to the remaining 0. Then subtract 2 – 1 = 1 Col 6) Remaining leading 0 can be ignored.
  • 14. Binary Subtraction Verification Verification 1100112  5110 - 111002 - 2810 2310 64 32 16 8 4 2 1 1 0 1 1 1 = 16 + 4 + 2 + 1 = 2310 1 1 0 0 1 1 - 1 1 1 0 0 2 0 0 2 1 2 1101 1 Subtract binary 11100 from 110011:
  • 15. Binary Subtraction Example 2 1 0 1 0 0 1 - 1 0 1 0 0 Example 2: Subtract binary 10100 from 101001 20 0 2 1101 0 Verification 1010012  4110 - 101002 - 2010 2110 64 32 16 8 4 2 1 1 0 1 0 1 = 16 + 4 + 1 = 2110
  • 16. Logical, Shift, and Rotate Operations
  • 17. Logical, Shift and Rotate Operations  A particular bit, or set of bits, within the byte can be set to 1 or 0, depending on conditions encountered during the execution of a program.  When so used, these bits are often called "flags".  Frequently, the programmer must manipulate these individual bits - an activity sometimes known as "bit twiddling".  The logical, shift, and rotate operations provide the means for manipulating the bits.
  • 18. Logical OR Rules OR Operations  OR Results in 1 if either or both of the operands are 1.  OR Table 0 OR 0 = 0 0 OR 1 = 1 1 OR 0 = 1 1 OR 1 = 1
  • 19. Logical OR Operation To perform the OR operation, take one column at a time and perform the OR operation using the OR table. Ex 1: 1 0 0 1 0 0 1 1 OR 0 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1
  • 20. Logical OR Examples Ex 3: 0 1 1 1 OR 0 0 1 0 0 1 1 1 Ex 2: 1 1 0 0 1 0 0 1 OR 0 0 0 0 1 0 1 0 1 1 0 0 1 0 1 1
  • 21. Logical XOR Rules XOR Operations  The exclusive OR. Similar to OR except that it now gives 0 when both its operands are 1. Rules. 0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0
  • 22. Logical XOR Examples Ex 1: 1 0 0 1 1 0 0 1 XOR 0 0 0 0 1 1 1 1 1 0 0 1 0 1 1 0 Ex 2: 0 1 1 1 XOR 0 0 1 0 0 1 0 1
  • 23. Logical AND Rules AND Operations  AND yields 1 only if both its operands are 1. Rules. 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1
  • 24. Logical AND Examples  Ex 1: 1 1 0 1 0 0 1 1 AND 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1  Ex 2: 0 1 1 1 AND 1 0 0 1 0 0 0 1
  • 25. Logical NOT NOT Operations  NOT is a separate operator for flipping the bits. Rules. NOT 0 = 1 NOT 1 = 0 Example. NOT 1 0 1 0 = 0 1 0 1
  • 26. Shift and Rotate operations Whereas logical operations allow the changing of bit values in place, SHIFT and ROTATE operations allow bits to be moved left or right without changing their values.
  • 27. Shift Left operation  SHL SHL (shift left) shifts each bit one place to the left. The original leftmost bit is lost and a 0 is shifted into the rightmost position. Ex 1. SHL 1 1 0 1 Ex 2. SHL 1 1 0 0 = 1 0 0 0 01 1 0 11 1 0 1 = 1 0 1 0
  • 28. Shift Left - Multiple Bits  SHL # bits means to shift left # times Ex 1: SHL 3 1 0 0 1 1 1 0 0 Ex 2: SHL 2 1 1 1 0 0 1 1 0 = 1 0 0 1 1 0 0 0 1 0 0 1 1 1 0 01 0 0 1 1 1 0 0 0 0 0 = 1 1 1 0 0 0 0 0
  • 29. Shift Right operation SHR SHR (shift right) shifts each bit one place to the right. The original rightmost bit is lost and a 0 is shifted into the leftmost position. Ex 1. SHR 1 0 1 1 Ex 2. SHR 0 0 1 1 = 0 0 0 1 0 1 0 1 1 = 0 1 0 1
  • 30. Shift Right – Multiple Bits  SHR # bits means to shift right # times Ex 1: SHR 3 1 0 0 1 1 1 0 0 0 0 0 1 0 0 1 1 1 0 0 = 0 0 0 1 0 0 1 1 Ex 2: SHR 2 1 1 1 0 0 1 1 0 = 0 0 1 1 1 0 0 1
  • 31. Arithmetic Shift Right operation ASR (retains rightmost sign bit) Shifts each bit one place to the right. The original rightmost bit is lost and a the value of the most significant bit (leftmost bit) is shifted into the new leftmost position. Ex 1. ASR 1 0 1 1 Ex 2. ASR 0 0 1 1 = 0 0 0 1 1 1 0 1 1 = 1 1 0 1
  • 32. Arithmetic Shift Right – Multiple Bits  ASR # bits means to arithmetic shift right # times Ex 1: ASR 3 1 0 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 0 0 = 1 1 1 1 0 0 1 1 Ex 2: ASR 2 0 1 1 0 0 1 1 0 = 0 0 0 1 1 0 0 1
  • 33. Rotate Left operation  ROL ROL (rotate left) shifts each bit one place to the left. The original leftmost bit is shifted into the rightmost position. No bits are lost. Ex 1. ROL 1 1 0 1 Ex 2. ROL 1 1 0 0 = 1 0 0 1 1 0 1 1
  • 34. Rotate Left – Multiple Bits  ROL # bits means to rotate left # times Ex 1: ROL 3 1 0 0 1 1 1 0 0 = 1 1 1 0 0 1 0 0 Ex 2: ROL 2 1 1 1 0 0 1 1 0 = 1 0 0 1 1 0 1 1
  • 35. Rotate Right operation  ROR ROR (rotate right) shifts each bit one place to the right. The original rightmost bit is shifted into the leftmost position. No bits are lost. Ex 1. ROR 1 0 1 1   Ex 2. ROR 0 0 1 1 = 1 0 0 1 1 0 11
  • 36. Rotate Right – Multiple Bits  ROR # bits means to rotate right # times Ex 1: ROR 3 1 0 0 1 1 1 0 0 = 1 0 0 1 0 0 1 1 Ex 2: ROR 2 1 1 1 0 0 1 1 0 = 1 0 1 1 1 0 0 1