Learning the Binary System

This is a VERY easy concept to learn, it's amazing that the binary system is not common knowledge! In fact it's easier than the system you already know!




Adding and Subtracting Binary Numbers


To add two numbers in binary, you do it the same way as you do in the decimal system, only it is much easier in binary. This is because you are only adding, or carrying, a 1, and the result in each column can only be a 1, or a 0. So here we go:

                0
            +   0
           -------
                0
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                1
            +   0
           -------
                1
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                
                1
            +   1
           -------
               10       A 1 is carried
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
               
                1
                1
            +   1
           -------
               11       A 1 is carried here too
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                1 
                1 
                1
            +   1
           --------     Here we just turn the problem with 4 numbers into 2 (we add the top 1 + 1, then the bottom 1 + 1)  
                10
            +   10
           --------     Then we just add those two
               100
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                1011011      In decimal this is :   91
            +   0111010                          +  58
           -------------                        -------
               10010101                            149
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

The last one here, is not realistic because the two numbers to be added were 7 bits long. Let's pad them (on the left of course so it doesn't change their value to make them 8 bits long).

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
               01011011      In decimal this is :   91
            +  00111010                          +  58
           -------------                        -------
               10010101                            149
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

All we did was add a zero to each number to bring it up to 8 bits in length. If we were working on a system where the registers WERE actually 7-bit, then we would have a problem because the result of the addition is 8 bits in length and the last bit (to the left) would be truncated (lost). The computer would see this if it had 7-bit registers:

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
               1011011      In decimal this is :   91
            +  0111010                          +  58
           -------------                        -------
               0010101                             21   !-- Wrong --!
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

That's it for addition, let's try some subtraction. Again, subtraction in binary is the same as in decimal. You borrow just like you would in the decimal system the only difference is that you are just working with 1 and 0. Here we go:

                0               Decimal: 0
            -   0                    -   0
           -------                  -------   
                0                        0
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                1               Decimal: 1
            -   0                    -   0
           -------                  -------
                1                        1
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                1               Decimal: 1
            -   1                    -   1
           -------                  -------
                0                        0
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
                10              Decimal: 2
            -   01                   -   1
           --------                 -------
                01                       1
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

You must remember, whenever you borrow, you are borrowing from two times the amount (one column to the left). Go over the following carefully. Here is an example of borrowing:

                10110               Decimal: 22
            -   01010                    -   10             Remember When Borrowing: It is the same as putting two ones over
           -----------                  -------                                      the borrowing column.
                 1100                        12
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

This is the same as doing this when you borrow:

                 1
                01110               
            -   01010               
           -----------                 
                 1100               
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        

Back to Index


External Links