Hardware Reference
In-Depth Information
A.5 BINARY ARITHMETIC
The addition table for binary numbers is given in Fig. A-8.
Addend
0
0
1
1
Augend
+0
+1
+0
+1
Sum
0
1
1
0
Carry
0
0
0
1
Figure A-8. The addition table in binary.
Two binary numbers can be added, starting at the rightmost bit and adding the
corresponding bits in the addend and the augend. If a carry is generated, it is car-
ried one position to the left, just as in decimal arithmetic. In one's complement
arithmetic, a carry generated by the addition of the leftmost bits is added to the
rightmost bit. This process is called an end-around carry. In two's complement
arithmetic, a carry generated by the addition of the leftmost bits is merely thrown
away. Examples of binary arithmetic are shown in Fig. A-9.
1's complement
2's complement
Decimal
10
00001010
11111100
00001010
11111101
+(
3)
+7
1 00000110
1 00000111
carry 1
discarded
00000111
Figure A-9. Addition in one's complement and two's complement.
If the addend and the augend are of opposite signs, overflow error cannot oc-
cur. If they are of the same sign and the result is of the opposite sign, overflow
error has occurred and the answer is wrong. In both one's and two's complement
arithmetic, overflow occurs if and only if the carry into the sign bit differs from the
carry out of the sign bit. Most computers preserve the carry out of the sign bit, but
the carry into the sign bit is not visible from the answer. For this reason, a special
overflow bit is usually provided.
 
 
 
Search WWH ::




Custom Search