460 Chapter 15
We can convert from a simple binary count to a two’s complement value very simply. For
positive numbers simply ensure that the MSB is a zero. To make a positive number into a
negative one, fi rst invert each bit and then add one to the LSB position thus:
9 1001 01001 5
9 01001 10110
10 2 2
10 2
c()using a bit word length
(^1) invert and add 1210111 c.
We must recognize that since we have fi xed the number of bits that we can use in each
word (in this example to 5 bits) then we are naturally limited to the range of numbers we
can represent (in this case from 15 through 0 to 16). Although the process of forming
two’s complement numbers seems lengthy, it is performed very speedily in hardware.
Forming a positive number from a negative one uses the identical process. If the binary
numbers represent an analogue waveform, then changing the sign of the numbers is
identical to inverting the polarity of the signal in the analogue domain. Examples of
simple arithmetic should make this a bit more clear:
Table 15.2 Examples of simple arithmetic
Decimal, base 10 Binary, base 2 2’s complement
Addition
12 01100 01100
3 00011 00011
15 01111 01111
Subtraction
12 01100 01100
3 00011 11101
9 01001
Since we have only a 5-bit word length any overfl ow into the column after the MSB
needs to be handled. The rule is that if there is overfl ow when a positive and a negative
number are added then it can be disregarded. When overfl ow results during the addition
of two positive numbers or two negative numbers then the resulting answer will be
incorrect if the overfl owing bit is neglected. This requires special handling in signal