You are on page 1of 2

Binary Arithmetic

Addition Adding unsigned numbers Adding unsigned numbers in binary is quite easy. Recall that with 4 bit numbers we can represent numbers from 0 to 15. Addition is done exactly like adding decimal numbers, except that you have only two digits (0 and 1). The only number facts to remember are that 0+0 = 0, with no carry, 1+0 = 1, with no carry, 0+1 = 1, with no carry, 1+1 = 0, and you carry a 1. so to add the numbers 0610=01102 and 0710=01112 (answer=1310=11012) we can write out the calculation (the results of any carry is shown along the top row, in italics). Decimal Unsigned Binary 1 (carry) 110 (carry) 06 0110 +07 +0111 13 1101 The only difficulty adding unsigned numbers occurs when you add numbers that are too large. Consider 13+5. Decimal Unsigned Binary 0 (carry) 1101 (carry) 13 1101 +05 +0101 18 10010 The result is a 5 bit number. So the carry bit from adding the two most significant bits represents a results that overflows (because the sum is too big to be represented with the same number of bits as the two addends).

Adding signed numbers Adding signed numbers is not significantly different from adding unsigned numbers. Recall that signed 4 bit numbers (2's complement) can represent numbers between -8 and 7. To see how this addition works, consider three examples. Decimal -2 +3 1 Decimal -5 +3 -2 Decimal -4 -3 -7 Signed Binary 1110 (carry) 1110 +0011 0001 Signed Binary 011 (carry) 1011 +0011 1110 Signed Binary 1100 (carry) 1100 +1101 1001

In this case the extra carry from the most significant bit has no meaning. With signed numbers there are two ways to get an overflow -- if the result is greater than 7, or less than -8. Let's consider these occurrences now. Decimal 6 +3 9 Decimal -7 -3 -10 Signed Binary 110 (carry) 0110 +0011 1001 Signed Binary 1001 (carry) 1001 +1101 0110

You might also like