It all adds up.
In this final section of the Binary Tutorial you will learn how to easily perform binary arithmetic (addition, subtraction, multiplication and division) by hand.
Binary arithmetic is one of those skills which you probably won't use very often. It can be very useful to know however. These processes are often stepping stones to more complex processes which can do very powerful things. Fortunately, they are not too difficult so with a bit of practice you'll be off and running in no time.
There are many calculators now which can do binary arithmetic for you. Just about every desktop OS, smart phone and tablet has one built in or one can easily be aquired. It is perfectly fine to use the calculator but we should know how to do it by hand as well. This will give us a much better understanding as to what is actually happening. That understanding is important in order to understand how certain mechanisms work (especially in computing). My recommnedation is to practice on paper by hand but use the calculator to verify your working.
Note: For educators, the interactive examples work well for demonstrations on a projector or smart board.
Binary addition is the easiest of the processes to perform. As you'll see with the other operations below, it is essentially the same way you learnt to do addition of decimal numbers by hand (probably many years ago in your early school years). The process is actually easier with binary as we only have 2 digits to worry about, 0 and 1.
The process is that we line the two numbers up (one under the other), then, starting at the far right, add each column, recording the result and possible carry as we go.
Here are the possibilities:
The carry is involved whenever we have a result larger than 1 (which is the largest amount we may represent with a single binary digit).
Here is an example:
(Note: The colour of the digits is only to help in aligning them up.)
(Note: To see the next step you may click the button 'Next Step' or click/ tap anywhere in the example area. Applies to this example and all the examples below.)
It is possible to add more than 2 binary numbers in one go but it can soon get unweildly managing the carries. My suggestion is that you add the 1st and 2nd numbers together. Then take the result and add the third number to that. Then take the result and add the 4th etc. This way you may add as many binary numbers as you like and the complexity will never increase. It's a little more work but with practice you will get very quick at it.
Binary multiplication is just about as easy as binary addition. Again it is the same process as we would do with decimal multiplication by hand. Again it is easier as binary only has 0 and 1.
We line the two numbers up (similar to addition). Then we multiply the entire top number by each individual digit of the bottom number. As we move across each digit we pad out the result with 0's to line it up. Finally we add all the results together.
Here are the possibilities:
Can't get much easier than that can it?
Here is an example:
As you have no doubt noticed, the process is fairly straight forward. If the binary digit on the second row we are multiplying by is a 1 then pad out accordingly and write out the top binary number. If the binary digit on the second row we are multiplying by is a 0 then we can just write out 0's.
If we want to multiply a binary number by another number which is a power of 2 then all we need to do is add the number of 0's representing that power to the right of the first number.
eg. 8 is 23 which is 1000 in binary.
101101 x 1000 = 101101000
With binary subtraction we start to get a little more difficult (But not that difficult). Similar to binary addition, we will work through the numbers, column by column, starting on the far right. Instead of carrying forward however, we will borrow backwards (when necessary).
Here are the possibilities:
Here is an example:
If we have multiple 0's in a row on the top number and need to borrow then things get a little interesting. It follows this general process:
Let's say we have 100 - 1
Sometimes you may have to do this over multiple columns but the process is the same.
The above example is the most convenient way for us to do binary subtraction by hand. There is another approach however and this is the way that computers subtract binary digits. This approach is called Two's Complement.
Let's say we want to compute 1000 ( 8 ) - 11 ( 3 ).
Binary division is probably the most difficult of the binary equations. Fortunately, it is also made easier by the fact we only have to deal with 1's and 0's.
First off, some terminology. The number we are dividing by is the divisor. The number we are dividing into is the dividend.
The process is as follows:
Well that was quite a bit to take in wasn't it. Let's look at an example to clear things up:
This stuff can be a little hard to get your head around. If you find reading through the material doing your head in a bit here's what I suggest:
So the best way to learn this stuff is to practice it and now we'll get you to do just that. For each of the activities below you can keep generating new numbers to try so keep working through them until you you're comfortable with them.
It may help to convert the numbers (working numbers and answer) to decimal after doing your working to confirm it is correct. (as opposed to just plugging it into a calculator)