Generally most numbers are signed by default for

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: gned) x; This code will set ux to ÍÅ Ü Û , where Û is the number of bits in data type int, since by Figure 2.9 we can see that the Û-bit two’s complement representation of ½ has the same bit representation as ÍÅ Ü Û . In general, casting from a signed value x to unsigned value (unsigned) x is equivalent to applying function Ì¾Í . The cast does not change the bit representation of the argument, just how these bits are interpreted as a number. Similarly, casting from unsigned value u to signed value (int) u is equivalent to applying function Í¾Ì . Practice Problem 2.13: Using the table you filled in when solving Problem 2.12, fill in the following table describing the function Ì¾Í : 46 CHAPTER 2. REPRESENTING AND MANIPULATING INFORMATION 2w +2w–1 Two’s Complement 0 2w–1 Unsigned 0 –2w–1 Figure 2.11: Conversion From Two’s Complement to Unsigned. numbers to large positive numbers. Function Ì¾Í converts negative ½ ¼ ¿ Ü Ì¾Í ´Üµ To get a better understanding of the relation between a signed number Ü and its unsigned counterpart Ì¾Í Û ´Üµ, we can use the fact that they have identical bit represen...
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