Page 373 - Analog and Digital Filter Design
P. 373

370 Analog and Digital Filter Design




                       Subtracting Two’s Complement Numbers
                       The principle of a carry still applies (where 1 is being subtracted from 0). Con-
                       sider a straightforward equation with a smaller number subtracted from a larger
                       one.

                             Number        0011,1110,1101,1001    (3ED9h or 16089)
                             Subtract      0010,0101,1101,0101    (25D5h or 9685)
                             Result        0001,1001,0000,0100    (1904h or 6404)

                       Now  consider  what  happens  when  the  number  being  subtracted  from  is
                       negative.
                             Number      1011,1110,1111,1000   (BEF8h or -4108h or -16648)

                             Subtract   0010,0101,1101,0101   (25D5h or 9685)
                             Result      1001,1001,0010,0011   (99231.1 or -66DDh  or -26333)

                       Two’s complement numbers are well behaved in both addition and subtraction
                       operations. The exception to this is when the number range is exceeded.

                       Multiplication
                       Consider a multiplication of two simple binary numbers.

                             Number #1       101 1          (Bh or 11)
                             Number #2       0111           (7h or 7)

                             Product         101 1
                                             + 1,0110
                                             + 10,1100
                             Result          0100,1101      (4Dh or 77)

                       So binary multiplication gives us the correct result, but in two’s complement
                       notation there are some complications. Multiplying two positive numbers gives
                       the correct result. However, the product of a positive and negative number, or
                       the product of two negative numbers, gives the wrong answer.

                       As an example, I will multiply two positive numbers 3Fh x 55 h = 14EBh (or
                       63 x 85 = 5355). This is shown by a series of binary additions.

                                       001 1,111 1    (3Fh)

                             X         0101,0101      (55W
   368   369   370   371   372   373   374   375   376   377   378