Page 855 - Mechanical Engineers' Handbook (Volume 2)
P. 855

846   Mechatronics

                                                                         Hexadecimal Binary
                                                                             0       0000
                                                                             1       0001
                                                                             2       0010
                                                                             3       0011
                                                                             4       0100
                                                                             5       0101
                                                                             6       0110
                                                                             7       0111
                                                                             8       1000
                                                                             9       1001
                                                                             A       1010
                                                                             B
                             7th bit        Kth bit      2nd bit  1st bit  0th bit  D  1011
                                                                                     1100
                                                                             C
                                                                                     1101
                                                                             E       1110
                            1   0   1   1   0   0   1   1
                                                                             F       1111
                                   Figure 30 A byte.            Figure 31 Hexadecimal-to-binary conversion.

           3.3  Binary Addition
                          Binary addition is straightforward and similar to decimal addition. The two numbers are first
                          aligned by their respective columns. Then the 1’s digits are added. If the result is greater
                          than the maximum allowable number for that column (i.e., 1), the remainder is carried into
                          the next column. This process is repeated until all columns are added and no remainder is
                          left:

                                                         3       011
                                                         1       001
                                                         4       100

           3.4  Two’s Complement Binary Numbers

                          Straight (regular) binary notation cannot represent a negative numbers. A new convention
                          called two’s complement binary numbers is used. Then binary arithmetic can be used to add
                          a positive number to a negative number and in this way it is possible to perform binary
                          subtraction. Consider a 3-bit two’s complement example:
                                                 (3-Bit Example)  For N bits
                                                 011         3        2  N-1
                                                 010         2
                                                 001         1
                                                 000         0
                                                                        0
                                                 111        1
                                                 110        2
                                                 101        3
                                                 100        4         -2 N-1
   850   851   852   853   854   855   856   857   858   859   860