1.4: Adding Binary Whole Numbers
( \newcommand{\kernel}{\mathrm{null}\,}\)
selected template will load here
This action is not available.
( \newcommand{\kernel}{\mathrm{null}\,}\)
Before moving on to how integer values are stored and used in a computer for calculations, how to do addition of binary whole numbers needs to be covered.
When 2 one-bit binary numbers are added, the following results are possible: 02+02 = 02; 02+12 = 12; 12+02 = 12; and 12+12 = 102. This is just like decimal numbers. For example, 3+4=7, and the result is still one digit. A problem occurs, however, when adding two decimal numbers where the result is greater than the base of the number (for decimal, the base is 10). For example, 9+8. The result cannot be represented in one digit, so a carry digit is created. The result of 9+8 is 7 with a carry of 1. The carry of 1 is considered in the next digit, which is actually adding 3 digits (the two addends, and the carry). So 39 + 28 = 67, where the 10's digit (4) is the result of the two addends (3 and 2) and the carry (1).
The result of 12+12 = 102 in binary is analogous to the situation in base 10. The addition of 12+12 is 02 with a carry of 12, and there is a carry to the next digit of 12.
An illustration of binary addition is shown in the figure below.
Here the first bit adds 12 +12, which yields a 02 in this bit and a carry bit of 12. The next bit now has to add 12 +12 +12 (the extra one is the carry bit), which yields a 12 for this bit and a carry bit of 12. If you follow the arithmetic through, you have 00112 (310) + 01112 (710) = 10102 (1010).