Page 50 - Cs_withBlue_J_C11_Flipbook
P. 50

Example 1: Given an 8-bit number and the signed magnitude binary representation is 00110100 , find its decimal
                                                                                                      2
              equivalent.

                                        0       0      1      1       0      1       0      0
                                      Sign bit                  Magnitude bits

              So, the sign is positive.
                                                     2
                                              4
                                       5
              Value of the number = 1 × 2  + 1 × 2  + 1 × 2   = 32 + 16 + 4 = 52
              Example 2: Given an 8-bit number and the signed magnitude binary representation is 10010101 , find its decimal
                                                                                                      2
              equivalent.
                                        1       0      0       1      0      1       0      1

                                      Sign bit                  Magnitude bits
              So, the sign is negative.

                                              2
                                                     1
              Value of the number = 1 × 2 + 1 × 2  + 1 × 2  = 16 + 4 + 1 = 21
                                       4
                                 = -21 (Since, the sign bit is 1)
              Advantage of signed magnitude:
              •  It is a simple representation in which we can easily determine whether a number is positive or negative by checking
                its leftmost sign bit.
              Disadvantages of signed magnitude:
              •  One of the bit patterns is wasted giving a reduced range of digits.
              •  Ambiguous representation of 0. Considering 8-bit byte, +0 is represented as 00000000 whereas -0 as 10000000.
              •  Care must be taken when adding numbers of like signs, since we may get incorrect results or an overflow can occur.

              Consider adding two positive 4-bit numbers +4 and +6.

                                                               +1
                                                       +4       0   1   0   0
                                                       +6   +   0   1   1   0
                                                                1   0   1   0

              Here, the sign bit is 1 which means overflow and the final answer 1010 is -2.
              Similarly, adding two negative numbers -4 and -6, we get:

                                                           +1 +1
                                                        -4      1   1   0   0
                                                        -6  +   1   1   1   0
                                                                1   0   1   0

              Here, final carry 1 is dropped due to limited space and final answer 1010 is -2.

              This problem can be tackled by promoting the values to larger bit fields by a technique called sign extension which is
              beyond the scope of this book.

              2.1.2 One’s Complement Notation
              One’s complement notation retains positive binary numbers in their original form (true form) and negative numbers
              by their changed notation.


                4848  Touchpad Computer Science-XI
   45   46   47   48   49   50   51   52   53   54   55