This preview shows page 1. Sign up to view the full content.
Unformatted text preview: bit representation Ü ½ Ü¼ . We claim that Ü¼ Ü ¾ . To see this, by Equation 2.1, we have ÈÛ ½ ¼ ÈÛ ½ Ü ¾ and Ü¼¼ È ½ Ü ¾ . We can therefore write Ü as Ü ¾ Ü¼ · Ü¼¼ . Ü ¼ Ü¾,Ü ¼ 2.3. INTEGER ARITHMETIC
Observe that ¼ 65
¾ Ü ¾ Ü¼¼ Ü¼ · Ü¼¼ ¾ È ½ ¾
¼ Ü¼ · Ü¼¼ ¾ ¼ ½ , and hence ¼ Ü¼ . Ü¼¼
Û ¾ , implying that
Û Ü¼¼ ¾ ¼ . Therefore Observe that performing a logical right shift of bit vector
Û Û This bit vector has numeric value Ü¼ . That is, logically right shifting an unsigned number by is equivalent to dividing it by ¾ . Therefore, for unsigned variable x, the C expression x >> k is equivalent to x / pwr2k, where pwr2k equals ¾k . Now consider the effect of performing an arithmetic right shift on a two’s complement number. Let Ü be the two’s complement integer represented by bit pattern ÜÛ ½ ÜÛ ¾ Ü¼ , and be in the range ¼ Û. Let Ü¼ be the two’s complement number represented by the Û bits ÜÛ ½ ÜÛ ¾ Ü , and Ü¼¼ be the unsigned number r...
View Full Document