Home TechnologyComputersPC Subscribe to RSS
 

How Do You Add Binary Numbers And How Do You Subtract Them?

Just need to know how to do it

Answer Question

1 Answer - Sort by: Date | Rating

    It is so simple that it is confusing.  Let's use 1011 and 0010 as two numbers we are going to add.  We will add right to left just like we would with base 10 numbers:

    Step 1
    1011
    0010
    -----
    ***1 --- 1 + 0 is 1 just like in base 10

    Step 2
    1011
    0010
    -----
    **01 --- 1 + 1 is 10 in base 2, so we put down a zero and carry the 1

    Step 3
    1011
    0010
    -----
    *101 --- remember the 1 we carried from the previous step?  We use it here

    Step 4
    1011
    0010
    -----
    1101 --- 1 + 0 = 1, just like before


    Subtraction can be done in the same manner (right to left with borrowing) but in binary there is a more efficient method known as "two's compliment".  Two's compliment is simply reversing all of the bits e.g. 1001 becomes 0110 and then adding 1 to the result: 0111.  Let's use the same numbers as in the previous example:


    Step 1
    1011 = 11 decimal
    0010 = 2 decimal

    We preform a two's compliment on the second number and then add it to the first the same way we did above:

    1011
    1110
    ----
    1001 = 9


    If you were following closely you might wonder what happened to the high order bit in the result.  The answer is that it is discarded.

    Hope this helps.
    1 0

    Boris 

    answered 2 years ago

      Answer Question - Answers are editable for 5 min.

      If you do not Sign-in or Register your answers will be anonymous,

      your answers may also be checked before going online.

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International