More commonly programming languages support xed

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ncate the 32-bit int to be a 16-bit short int. As we saw before, this 16-bit pattern is the two’s complement representation of 12,345. When we cast this back to int, sign extension will set the high-order 16 bits to 1s, yielding the 32-bit two’s complement representation of 12,345. When truncating a Û-bit number Ü ÜÛ ½ ÜÛ ¾ ܼ to a -bit number, we drop the high-order Û bits, giving a bit vector ܼ Ü ½ Ü ¾ ܼ . Truncating a number can alter its value—a form of overflow. We now investigate what numeric value will result. For an unsigned number Ü, the result of truncating it to bits is equivalent to computing Ü ÑÓ ¾ . This can be seen by applying the modulus operation to Equation 2.1: ¾Í Û ´ ÜÛ Ü ½ Û Ü¼ µ ÑÓ Û ½ ¼ ¾ ܾ ܾ ÑÓ ¾ ½ ½ ¼ ¼ ÑÓ ¾ ܾ ´ ¾Í Ü Ü ½ ܼ µ 52 CHAPTER 2. REPRESENTING AND MANIPULATING INFORMATION ÑÓ ¾ ¼ In È the½ above derivation we make use of the property that ¾ ¾ ¾ ½ ¾ . ¼ for any , and that È ½ ¼...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online