Page 283 - FUNDAMENTALS OF COMPUTER
P. 283

NPP













                  NPP               Number System, Boolean Algebra and Logic Circuits              283


                   3.34 Signed Integer Arithmetic             3.34 gmBÝS> nyUmªH$ A§H$J{UV
                  (2's Complement addition and subtrac-       (2's H$m°påßb_|Q> Omo‹S> d KQ>md)
                  tion)
                      Positive Integers  have unique  represen-   YZmË_H$ nyUmªH$ H$mo EH$ hr VarHo$ go Xem©`m Om
                  tation; signed-Magnitude, but negative      gH$Vm h¡ ; gmBÝS> _op½ZQ²>`yS> à{V{Z{YËd Ÿ& na§Vw F$UmË_H$
                  numbers  can be  represented  in three ways;
                  signed-magnitude, signed- 1's complement and  nyUmªH$ H$mo VrZ àH$ma go Xem©`m Om gH$Vm h¡ ; gmBÝS>
                  signed- 2's  complement representation.  First  _op½ZQ²>`yS>, gmBÝS> 1's H$m°påßb_|Q> VWm gmBÝS> 2's
                  two are rarely used because there are different  H$m°påßb_|Q> & àW_ XmoZm| H$m Cn`moJ AË`§V H$_ hmoVm h¡
                  representations of  +0  and –0.  But in 2's  Š`m|{H$ BZ_| + 0 VWm -0 Ho$ Xmo AbJ-AbJ ê$n hmoVo
                  complement  representation  both + 0 and  –  0  h¢ & bo{H$Z 2's H$m°påßb_|Q> _|  + 0 VWm - 0 Ho$ {bE
                  have only  one  representation. Therefore  2's
                  complement method is used extensively. Here  EH$ hr à{V{Z{YËd hmoVm h¡Ÿ& Bg{bE BgH$m AË`{YH$
                  Binary addition and subtraction as applicable  Cn`moJ {H$`m OmVm h¡& h_ ~mBZar _| Omo‹S> VWm KQ>md H$s
                  to signed integers will be discussed:       MMm© H$a|JoŸ&
                  2's Complement Addition (Signed)            gmBÝS> 2's H$m°påßb_|Q> Omo‹S> (gmBªS>)

                      This method is straight forward; represent  `h ~hþV hr gab {d{Y h¡& Bg_| YZmË_H$ nyUmªH$m|
                  positive operands  using  signed magnitude  H$mo gmBÝS> _op½ZQ²>`yS> go VWm F$UmË_H$ nyUmªH$m| H$mo gmBÝS>
                  representation and negative operands using 2's
                  complement representation.  Add both the    2's H$m°påßb_|Q> go Xem©Vo h¢Ÿ& XmoZm| H$mo Omo‹S> XoVo h¢ VWm
                  binary numbers  and neglect any  end carry.  A§{V_ hm{gb H$mo N>mo‹S> XoVo h¢& A~ EH$ CXmhaU boH$a
                  Consider the case in which both the numbers  g_PVo h¢ {Og_| XmoZm| g§»`mE± YZmË_H$ h¢…
                  are positive  :
                                                       (+13) + (+12)
                      Take sufficient number of bits to avoid the  g_w{MV g§»`m _| {~Q>| boVo h¢ {Oggo Amodaâbmo H$s
                  problem of overflow. Starting by taking 8-bits  g_ñ`m go ~Mm Om gHo$&$`hm± h_ 8-{~Q>m| _| (+13) d
                  to represent +13 and +12.
                                                              (+ 12) H$mo Xem©H$a Omo‹S>Vo h¢ …
                                          +  ( 13+  ) →   0000 1 1 0 1
                                             ( +  +  ) 12  →+  0000 1 1 00
                                                          000 1 1 00 1

                      Since MSB is 0 the result is positive integer  MSB Ho$ ñWmZ na 0 h¡ Omo Xem©Vm h¡ {H$ n[aUm_
                  and the remaining  bits  show the magnitude.  YZmË_H$ h¡ Ÿ& ~mH$s H$s {~Q>| CgH$m n[a_mU ~VmVr h¢, Omo
                  The magnitude 11001 can be  evaluated to    {H$ 11001 h¡ & BgH$m Xe_bd _mZ 25 AmVm h¡ Ÿ&
                  decimal 25. Therefore
                                                              AV… h_ {bI gH$Vo h¢ {H$
                                                      (+13) + (+12) = +25
                      Now consider another problem in which       A~ EH$ Xygar g_ñ`m bmo {Og_| EH$ nyUmªH$ YZmË_H$
                  one integer is positive and another is negative.  VWm Xygam F$UmË_H$ h¡ Ÿ&

                                                         (+17) + (–26)
   278   279   280   281   282   283   284   285   286   287   288