@@ -109,13 +109,13 @@ In ones’ complement arithmetic, a negative integer (-x) is represented
109109as the complement of x; that is, each bit of x is inverted. When adding
110110numbers in ones’ complement arithmetic, a carryout from the most
111111significant bit needs to be added to the result. Consider, for example,
112- the addition of -5 and -3 in ones’ complement arithmetic on 4-bit
113- integers: +5 is 0101, so -5 is 1010; +3 is 0011 , so -3 is 1100 . If we
114- add 1010 and 1100 , ignoring the carry, we get 0110 . In ones’ complement
112+ the addition of -5 and -2 in ones’ complement arithmetic on 4-bit
113+ integers: +5 is 0101, so -5 is 1010; +2 is 0010 , so -2 is 1101 . If we
114+ add 1010 and 1101 , ignoring the carry, we get 0111 . In ones’ complement
115115arithmetic, the fact that this operation caused a carry from the most
116- significant bit causes us to increment the result, giving 0111 , which is
117- the ones’ complement representation of -8 (obtained by inverting the
118- bits in 1000 ), as we would expect.
116+ significant bit causes us to increment the result, giving 1000 , which is
117+ the ones’ complement representation of -7 (obtained by inverting the
118+ bits in 0111 ), as we would expect.
119119
120120The following routine gives a straightforward implementation of the
121121Internet’s checksum algorithm. The ``count `` argument gives the length
0 commit comments