7 6 5 4 3 2 1 O
Shift Right Operation
Miero ls one problem willi shlh rlglits wlth res|x*ct to dlvislon as descrlbed above a shlft right ls only equlvalonl to an u/i-s/^neddlvlslon by iwo. Koi example. Ifyou slilft tbe iinstgned representatlon of 254 (OFEIt) ono place to tho right. yon got I27 (07 Fh). exactiy w bat you wonld expect. I Iowever. ifyou shlft tbe blnary representatlon of -2 (OFEh) to tbe right one posltlon, you gol I27 (071 h). whlcb ls not correct. 1 his problem occurs because w e ro shlft Ing a /ero Into bil sovon If bit soven prevlously contalned a one. wo ro chang Ing it front a negatlve to a posilive nuinber. Not <i go(xl thlttg whon dlvldlng by iwo.
Io uso tho shlft right as a dlvtslon operator, we musi dolino a thlrd shlft operation: aritlunetic shift right7. An arlthmetlc shlft right worksJust like the normal shlft right opera-tion (a logical shift right) wlth one exceplion: instead of shlftlng a /ero into bit seven. an arlthmetlc shlft right operation Ieaves bit sevon alone. that ls. dnring tho shlft operation ii doesnot modlfy tho value ol bit sevon as Figuro I.IOshows.
7 6 5 4 3 2 1 0
: Arithmetic Shift Right Operation