Logic gates and Binary Operations
Logic gates
• Three basic logic gates ( AND, OR, Not)
One’s Complement
• Change (0) to (1) and (1) to (0)
Examples
• Example-1: Find 1’s complement of binary number 10101110.
• Simply invert each bit of given binary number, so 1’s
complement of given number will be 01010001.
• Example-1: Find 1’s complement of binary number 1000000.
Two’s Complement (The Negative
Number )
• 2’s complement of a binary number is 1 added to the 1’s
complement of the binary number.
Examples
• Find the two’s complement of (00011100 )?
Step 1 : Find the One’s Complement by changing the 1 to 0 and 0 to 1
11100011
Step 2 : Add 1
11100011
1
11100100
+
Result:
Subtraction with One’s Complement
• Y = A-B = A(-B)
• Step1: Find the one’s Complement of (B)
• Step 2: Add A and B
• Step 3:
• if there is a carry, remove it from the end of the number add it to the
number , The result will be a Positive value means (+Y) ( A>B)
• if there is NO carry, remove the carry bit from end of the number add take
the on’es complement of the result. The result will be a negative number (-Y)
means (A<B)
•
Example -1
• Y= 15 -10
• Subtract (1010)2 from (1111)2
Example-2:
• Y = 8-10
• Subtract (1010)2 from (1000)2 using 1’s complement method.
Subtraction with Two’s Complement
• Y = A-B = A(-B)
• Step1: Find the Two’s Complement of (B)
• Step 2: Add A and B
• Step 3:
• if there is a carry, Omit it from the number, The result will be a Positive value
means (+Y) ( A>B)
• if there is NO carry, take the Two’s complement of the result. The result will
be a negative number (-Y) means (A<B)
•
Exampe-1:
• Y = 15-10
• Subtract (1010)2 from (1111)2 using 2’s complement method.
Example-2:
• Y=8-10
• Subtract (1010)2 from (1000)2 using 2’s complement.
Exercises
• Find the Subtraction of these numbers using both 1’s complement
and 2’s Complement ? Compare the Results?
• A= 243 , B= 123
•Find
• Y=A-B
• Y=B-A
For fun
• Solve these two equations
• A = 12 B= 3 Find
• 1) Find Y=A*B
• 2) Find Y = A/B

Binary Operations: The Foundation of Mathematics.pptx

  • 1.
    Logic gates andBinary Operations
  • 3.
    Logic gates • Threebasic logic gates ( AND, OR, Not)
  • 6.
    One’s Complement • Change(0) to (1) and (1) to (0)
  • 7.
    Examples • Example-1: Find1’s complement of binary number 10101110. • Simply invert each bit of given binary number, so 1’s complement of given number will be 01010001. • Example-1: Find 1’s complement of binary number 1000000.
  • 8.
    Two’s Complement (TheNegative Number ) • 2’s complement of a binary number is 1 added to the 1’s complement of the binary number.
  • 9.
    Examples • Find thetwo’s complement of (00011100 )? Step 1 : Find the One’s Complement by changing the 1 to 0 and 0 to 1 11100011 Step 2 : Add 1 11100011 1 11100100 + Result:
  • 10.
    Subtraction with One’sComplement • Y = A-B = A(-B) • Step1: Find the one’s Complement of (B) • Step 2: Add A and B • Step 3: • if there is a carry, remove it from the end of the number add it to the number , The result will be a Positive value means (+Y) ( A>B) • if there is NO carry, remove the carry bit from end of the number add take the on’es complement of the result. The result will be a negative number (-Y) means (A<B) •
  • 11.
    Example -1 • Y=15 -10 • Subtract (1010)2 from (1111)2
  • 12.
    Example-2: • Y =8-10 • Subtract (1010)2 from (1000)2 using 1’s complement method.
  • 13.
    Subtraction with Two’sComplement • Y = A-B = A(-B) • Step1: Find the Two’s Complement of (B) • Step 2: Add A and B • Step 3: • if there is a carry, Omit it from the number, The result will be a Positive value means (+Y) ( A>B) • if there is NO carry, take the Two’s complement of the result. The result will be a negative number (-Y) means (A<B) •
  • 14.
    Exampe-1: • Y =15-10 • Subtract (1010)2 from (1111)2 using 2’s complement method.
  • 15.
    Example-2: • Y=8-10 • Subtract(1010)2 from (1000)2 using 2’s complement.
  • 16.
    Exercises • Find theSubtraction of these numbers using both 1’s complement and 2’s Complement ? Compare the Results? • A= 243 , B= 123 •Find • Y=A-B • Y=B-A
  • 17.
    For fun • Solvethese two equations • A = 12 B= 3 Find • 1) Find Y=A*B • 2) Find Y = A/B