CSC110 - Computer Mathematics

Module 3 Section 1 - Binary addition and subtraction

In counting binary numbers, we have already been performing binary addition; that is, we are quite experienced in adding '1' to any binary number. Adding large binary numbers together works the same way as adding decimal numbers, so let's review that first.

Adding the decimal numbers 274 and 352 is shown below. The algorithm starts with the least significant digit and works from right to left. For each place position, the digit from the top and bottom number is summed. If the result is a single digit, it is written in the final sum in the same place value position. If the result is two digits, then the least significant is written in that place value position in the sum, and the most significant is carried to the next, more significant place value position, where it is added with those digits.

Binary addition works in the same way. Here is an example of adding '0111' with '0101'.

Binary subtraction can also be performed using the same algorithm most of us have learned for decimal substraction. Consider this example in which '154' is subtracted from '603'. Subtraction proceeds right to left. The bottom digit is subtracted from the top digit, and the result written in the place value position in the result. If the top digit is less than the bottom digit, then we must 'borrow' from the next place value position. That means decrementing the top digit in the next significant position and adding the base to the top digit of this position before performing the subtraction. This gets even more complicated if the position we wish to borrow from has a '0' in it! In this case, we must cascade the borrow to the next significant position. This happens in our example when we subtract the '4' from the '3'. We must borrow, but the next position has a '0', so we move on to the '6'.

This algorithm can get very complicated, and the amount of time it takes to perform the subtraction can vary greatly. Wouldn't it be nice if we had a subtraction algorithm as simple and predictable as addition? Well, we already have that algorithm. It is the addition algorithm itself. Think about it. How can you use addition to compute "A - B"? Of course! Convert 'B' to 'negative B' and add them, like this: A+(-B). This way, you could use your addition algorithm to perform subtraction.

The only problem is, we have yet to see how negative numbers are represented in binary. That's a topic for the next section.

Homework Questions

    Perform binary addition
  1. 10 + 1
  2. 11 + 1
  3. 1011011 + 101
  4. 1100000 + 1101
  5. 1111111 + 1
  6. 1111111 + 10
  7. 1011111 + 1
  8. 100110 + 110101
  9. 111010 + 110100
  10. 110100101 + 101011011
  11. 111001110 + 110101011
  12. 11011 + 11011
  13. 10101 + 10101
  14. 100110 + 100110
  15. 101011 + 1101110101
  16. 111000 + 101110111
  17. 101011 + 11011
  18. 111 + 1000
  19. 11111 + 11111
  20. 1101 + 0
Next Section: Negative Binary Numbers
Return to Module Index