ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Digital Logic and Design
    PHYS4129
    Progress0 / 20 topics
    Topics
    1. Review of Number Systems: Binary, octal and hexadecimal number system their inter conversion2. Basic logic gates3. Different codes: BCD, ASCII, Gray etc.4. Parity in codes5. Boolean Algebra: Demorgan theorems6. Simplification of Boolean expression by Boolean postulates and theorem7. SOP and POS conversions8. K maps and their uses9. Don't care condition10. Combinational Logic Circuit: Logic circuits based on AND-OR, OR-AND, NAND, NOR Logic gates design11. Addition, subtraction, 2's compliments12. Half adder, full adder13. Half subtractor, full subtractor14. Encoder, decoder15. Multiplexer and demultiplexer16. Sequential Logic Circuit: Latches17. Flip-flops: S-R, J-K, T and D flip flops18. Master-slave flip-flops19. IC Logic Families: Basic characteristics (Propagation delay time, dissipation, noise margins etc.)20. Different logic based IC families: DTL, RTL, TTL, CMOS
    PHYS4129›Addition, subtraction, 2's compliments
    Digital Logic and DesignTopic 11 of 20

    Addition, subtraction, 2's compliments

    5 minread
    836words
    Beginnerlevel

    Addition, Subtraction, and 2’s Complement in Digital Logic

    In digital systems, arithmetic operations such as addition and subtraction are essential for performing calculations. These operations are typically carried out using binary numbers, which are represented by combinations of 0s and 1s. To handle negative numbers and subtraction, a system known as 2’s complement is commonly used.


    1. Binary Addition

    Binary addition is similar to decimal addition but is based on the binary number system (base 2). The rules for binary addition are:

    Bit 1 Bit 2 Sum (S) Carry (C)
    0 0 0 0
    0 1 1 0
    1 0 1 0
    1 1 0 1
    • Carry is the extra bit that is carried over to the next higher bit.
    • When adding 1 + 1, the result is 0 with a carry of 1, just like in decimal addition when 9 + 1 gives 10.

    Example of Binary Addition:

    Let's add two binary numbers: 1011 (11 in decimal) and 1101 (13 in decimal).

      1011   (11)
    + 1101   (13)
    ---------
     11000   (24)
    
    • Starting from the rightmost bit, you add column by column.
    • If there's a carry, you add it to the next higher bit.
    • The final result is 11000, which is 24 in decimal.

    2. Binary Subtraction

    Binary subtraction is done using the concept of borrowing, just like in decimal subtraction. However, binary subtraction uses the rules of binary arithmetic to handle borrowing.

    The subtraction rules for binary are:

    Bit 1 Bit 2 Difference (D) Borrow (B)
    0 0 0 0
    0 1 1 (borrow) 1
    1 0 1 0
    1 1 0 0

    Example of Binary Subtraction:

    Let's subtract 1101 (13 in decimal) from 1011 (11 in decimal).

    1. 1011 - 1101:
      To subtract, we need to borrow from the next higher bit.

        1011
      - 1101
      --------
        1110  (Negative result)
      

      But binary subtraction is more efficient when we use 2's complement to represent negative numbers. Let's now look at 2’s complement to handle negative numbers.


    3. 2’s Complement Representation

    In binary arithmetic, the 2’s complement system is widely used to represent negative numbers. It allows the subtraction of numbers by simply adding their 2’s complement, avoiding the need for explicit subtraction.

    How to Find the 2’s Complement:

    To find the 2's complement of a binary number:

    1. Invert all the bits (1 becomes 0 and 0 becomes 1).
    2. Add 1 to the result.

    Example: Finding 2’s Complement

    Let's find the 2's complement of 1011 (11 in decimal).

    1. Invert all bits of 1011:

      • 1011 becomes 0100.
    2. Add 1 to 0100:

      • 0100 + 1 = 0101, which is 5 in decimal.

    Thus, the 2's complement of 1011 is 0101. The result represents -5 in decimal.

    Addition Using 2’s Complement

    Subtraction can be easily done by converting the subtrahend (the number to be subtracted) to its 2’s complement and then adding it to the minuend (the number from which subtraction is being done).

    Example: 2’s Complement Subtraction

    Suppose you want to subtract 6 from 11 (i.e., 11 - 6).

    1. Convert 6 to binary: 6 in binary is 0110.

    2. Find the 2's complement of 6:

      • Invert 0110: 1001
      • Add 1: 1001 + 1 = 1010, so the 2's complement of 6 is 1010.
    3. Add the 2's complement of 6 to 11:

      • 11 in binary is 1011.
      • Add the 2’s complement of 6 (1010) to 1011:
        1011
      + 1010
      ------
       10101
      
    4. Discard the carry bit: The final result is 0101, which is 5 in decimal, confirming that 11 - 6 = 5.


    Summary of 2’s Complement Operations

    • Addition: When adding binary numbers, just follow the usual addition rules (carry, no carry).
    • Subtraction: Convert the number to be subtracted into its 2's complement and then add it to the original number. If the result overflows (has a carry-out), discard it.
    • Representation of Negative Numbers: In a system using 2’s complement, negative numbers are represented by finding the 2’s complement of their absolute value.

    Advantages of 2’s Complement

    1. Single Representation for Zero: In 2's complement, there is only one way to represent zero, which avoids the issue of having two representations for zero (positive and negative) as in sign-magnitude representation.

    2. Simpler Hardware Design: Arithmetic operations like addition and subtraction can be performed using the same hardware for both positive and negative numbers, simplifying circuit design.

    3. Efficient Subtraction: Subtraction is handled by addition of 2's complement, which simplifies hardware design and avoids the need for a separate subtraction circuit.


    Conclusion

    • Addition in binary follows simple rules, where a carry is passed to the next higher bit if the sum of two bits is 1.
    • Subtraction can be tricky, but using the 2’s complement method simplifies this by turning subtraction into addition.
    • 2’s complement is widely used in computer systems for representing negative numbers and performing subtraction, making the system more efficient by using the same addition logic for both positive and negative numbers.
    Previous topic 10
    Combinational Logic Circuit: Logic circuits based on AND-OR, OR-AND, NAND, NOR Logic gates design
    Next topic 12
    Half adder, full adder

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time5 min
      Word count836
      Code examples0
      DifficultyBeginner