Page 64 - Engineering Digital Design
P. 64

2.4 UNSIGNED BINARY CODED DECIMAL, HEXADECIMAL, AND OCTAL            35


                                 Table 2.2 BCD bit patterns and decimal equivalent

                                  BCD                     BCD
                                Bit Pattern  Decimal    Bit Pattern  Decimal
                                  0000         0          1000         8
                                  0001          1         1001         9
                                  0010         2          1010        NA
                                  0011         3          1011        NA
                                  0100         4          1100        NA
                                  0101         5          1101        NA
                                  0110         6          1110        NA
                                  0111         7          1111        NA
                                NA = not applicable (code words not valid)



                 polynomials of the form

                                                              1
                                                      2
                                              3
                                   #10 = b 3 x 2  + b 2 x 2  + b\ x 2  + b 0 x 2°
                                      = & 3 x 8 + £ 2 x 4 + b, x 2 + £ 0 x 1
                 for any b^bibo code integer. Thus, decimal 6 is represented as (0 x 8) + (1 x 4) + (1 x
                 2) + (0 x 1) or 0110 in BCD code. As in binary, the bit positional weights of the BCD code
                 are derived from integer powers of 2". Table 2.2 shows the BCD bit patterns for decimal
                 integers 0 through 9.
                    Decimal numbers greater than nine or less than one can be represented by the BCD code
                 if each digit is given in that code and if the results are combined. For example, the number
                 63.98 is represented by (or converted to) the BCD code


                                                6 3.9         8
                                      63.98io = (01100011 . 1001 1000) BCD
                                            = 1100011.1001IBCD

                 Here, the code weights are 80, 40, 20, 10; 8, 4, 2, 1; 0.8, 0.4, 0.2, 0.1; and 0.08, 0.04, 0.02,
                 0.01 for the tens, units, tenths, and hundredths digits, respectively, representing four decades.
                 Notice that the leading and trailing O's can be dropped. Pencil-and-paper conversion between
                 binary and BCD requires conversion to decimal as an intermediate step. For example, to
                 convert from BCD to binary requires that groups of four bits be selected in both directions
                 from the radix point to form the decimal number. If necessary, leading and trailing zeros
                 are added to the leftmost or rightmost ends to complete the groups of four bits as in the
                 example above. Negative BCD numbers are coded by using 10's complement notation as
                 discussed in a later section.
                    Another code that is used for number representation and manipulation is called Excess
                 3 BCD (or XS3 BCD or simply XS3). XS3 is an example of a biased-weighted code (a bias
                 of 3). This code is formed by adding 001 b (= 3io) to the BCD bit patterns in Table 2.2.
   59   60   61   62   63   64   65   66   67   68   69