Page 96 - Bebop to The Boolean Boogie An Unconventional Guide to Electronics Fundamentals, Components, and Processes
P. 96

Binary Arithmetic    77

           calculations on the right are all simple additions, regardless of whether the
           individual values are positive or negative.
               If computers were forced to use a binary version of the sign-magnitude form
           to perform additions, they would have to perform a sequence of operations
           (Figure 8-11).







              IF THE SIGN5 ARE THE SAME:           IF THE 5IGNS ARE DIFFERENT:
                Add the values.  Note that the       5ubtract the smaller value from
                result will always have the same     the larger value, then attach
                sign as the original values.         the correct sign to the result.



                      Figure 8-1 1. Steps required for sign-magnitude additions


               As well as being time consuming, performing all these operations would
           require a substantial number of logic gates. Thus, the advantages of using
           the signed binary format for addition operations are apparent: signed binary
           numbers can always be directly added together to provide the correct result in
           a single operation, regardless of whether they represent positive or negative
           values. That is, the operations a + b,  a + (-b),  (-a)  + b, and (-a)  + (-b)  are all
           performed in exactly the same way, by simply adding the two values together.
           This results in fast computers that can be constructed using a minimum number
           of logic gates.
               Now consider the case of subtraction. We all know that 10 - 3 = 7 in
           decimal arithmetic, and that the same result can be obtained by negating the
           right-hand value and inverting the operation: that is, 10 + (-3)  = 7. This
           technique is also true for signed binary arithmetic, although the negation of the
           right hand value is performed by taking its twos complement rather than by
           changing its sign. For example, consider a generic signed binary subtraction4



           4 For the sake of simplicity, only the case of a - b is discussed here. However, the operations a - b,
                    (-a)
                         b,
                        -
            a - (4), andl (-a)  - (4) are all performed in exactly the same way, by simply taking the
            twos complement of  b and adding the result to a, regardless of whether a and b represent positive
            or negative values.
   91   92   93   94   95   96   97   98   99   100   101