Of course this may not be possible when the

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: dentical unsigned and two’s complement representations. For values outside of this range, the conversions either add or subtract ¾Û . For example, we have Ì¾Í Û ´ ½µ ½ · ¾Û ÍÅ Ü Û —the negative number closest to 0 maps to the largest unsigned number. At the other extreme, one can see that Ì¾Í Û ´ÌÅ Ò Û µ ¾Û ½ · ¾Û ¾Û ½ ÌÅ Ü Û · ½—the most negative number maps to an unsigned number just outside the range of positive, two’s complement numbers. Using the example of Figure 2.10, we can see that Ì¾Í ½ ´ ½¾ ¿ µ ¿ · ½¾ ¿ ¿ ½ ½. 2.2.4 Signed vs. Unsigned in C As indicated in Figure 2.8, C supports both signed and unsigned arithmetic for all of its integer data types. Although the C standard does not specify a particular representation of signed numbers, almost all machines use two’s complement. Generally, most numbers are signed by default. For example, when declaring a constant such as 12345 or 0x1A2B, the value is considered signed. To create an unsigned constant, the character ‘U’ or ‘u’ must be added as suffix, e.g., 12345U or 0x1A2Bu. C allows conversion between unsigned and signed. The rule is that the underlying bit representation is not changed. Thus, on a two’s complement machine, the effect is to apply the fun...
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