Page 92 - Engineering Digital Design
P. 92

2.9 BINARY ARITHMETIC                                                 63


                  EXAMPLE 2.32
                                 056io ->     0000 0101 OllOfiCD Augend A BCD
                                +06910 -> +0000 0110 lOOlgcp Addend B BCD
                                  125,0       0000 1011 1111    Sum
                                                   0110 0110    Correction
                                                 1 1111 110      Carries
                                              0001 0010 0101 BCD Result = 125 w
                    The following algorithm generalizes the process just given for operands having both
                  integers and fractions.


                                         Algorithm 2.14: A BCD + BBCD
                   (1) Set BCD operands in descending decade order, ABCD = • • • AiooAioAjA.iA.oi • • •
                   and BBCD = • • • B mBi QB { B A B M • • • such that the MSDs for A and B are 0000 (null).
                   (2) Set i = LSD for matching operand decades.
                   (3) If A f + Bi > 1001 by Algorithm 2,8, add 0110 to that result and carry 0001 over
                   to the next MSD. If A ( + B { < 1001, add 0000 to the result and carry 0000 to the next
                   MSD.
                                                                          l
                                                                              2
                                                                                   3
                   (4) Repeat steps (2) and (3) for matching decades in the order of W i, I0 i, 10 z,...,
                   MSD.
                  BCD Subtraction  Negative BCD numbers are most conveniently represented in 10's
                  complement (IOC). This permits negative BCD numbers to be added according to Algo-
                  rithm 2.14. The result, if negative, will be represented in IOC form requiring negation to
                  obtain the true value.
                  EXAMPLE 2.33
                      08.25io -»   08.25,0   ->    0000 1000.0010 0101 BCD
                    -13.52,0 -> +86.48| OC ->     +1000 0110.0100 1000 BCD) IOC
                    -05.27,0       94.73 ,oc       1000 1110.0110 1101        Sum
                                                 +      0110       0110       Correction
                                                      1 11       1_J          Carries
                                                   1001 0100.0111 0011 BCD) 10C Result
                  The true (absolute) value of the result is found by negation to be

                                94.73,oc)ioc = 05.27,0 or 0000 0101.0010 Oil 1 BCD-

                    Note that to convert directly from the BCD form, flCD), 0c = N 2c + 1010 = N 2 +
                  ILSB + 1010 for the LSD but thereafter is fiCD), oc = N 2 + 1010 = N 9C, discarding any
                  carry overflow in either case.
                    The following algorithm generalizes the process of BCD subtraction.


                               Algorithm 2.15: A BCD + B BCD) m or A BCD) 10C + B BCD) m
                   (1) Convert any negative decimal number to its 10's complement (IOC) by Algorithm 2.5
                   with r = 10.
   87   88   89   90   91   92   93   94   95   96   97