Page 71 - Engineering Digital Design
P. 71

42              CHAPTER 2 / NUMBER SYSTEMS, BINARY ARITHMETIC, AND CODES


                    Terminating a fraction conversion at n digits (to the right of the radix point) results in an
                    error or uncertainty. This error is given by




                                     = r           , <2-(n+/) r


                    where the quantity in brackets is less than (a- n + 1). Therefore, terminating a fraction
                    conversion at n digits from the radix point results in an error with bounds

                                                        n
                                               0 < e < r- (a- n + 1).                   (2.9)
                    Equation (2.9) is useful in deciding when to terminate a fraction conversion.
                       Often, it is desirable to terminate a fraction conversion at n + 1 digits and then round off
                    to n from the radix point. A suitable method for rounding to n digits in radix r is:


                         Algorithm 2.4: Rounding Off to n Digits for Fraction Conversion in Radix r
                     Perform the fraction conversion to (n — 1) digits from the radix point, then drop the
                                                   M 1)
                     (n — 1) digit if «_( K+1) < r/2; add r~< ~'  to the result if #_ (w _i) > r/2.

                       After rounding off to n digits, the maximum error becomes the difference between the
                    rounded result and the smallest value possible. By using Eq. (2.9), this difference is


                                              n
                                       nax = r (a_ n + l)-r "( a_,

                                          = r-"|l-

                    Then, by rounding to n digits, there results an error with bounds






                                                                               n
                    If a-( n+\) < r/2 and the (n + 1) digit is dropped, the maximum error is r . Note that for
                    N s —> NIQ —>• N r type conversions, the bounds of errors aggregate.
                      The fraction conversion methods given in Table 2.5 and Algorithms 2.3 and 2.4 are
                    illustrated by the following examples:

                    EXAMPLE 2.7 0.654 10 -> 7V 2 rounded to 8 bits:
                                       •N s x r  F   I
                                     0.654 x 2 0.308 1
                                     0.308 x 2 0.616 0
                                     0.616 x 2 0.232 1
                                     0.232 x 2 0.464 0
   66   67   68   69   70   71   72   73   74   75   76