324_Book

# 12 for small numbers the conversion from unsigned to

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

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: s bit has positive or negative weight. Consider the following function: Í¾Ì Û ´Üµ ¾Ì Û ´Í¾ Û ´Üµµ. This function takes a number between ¼ and ¾Û ½ ½ and yields a number between ¾Û ½ and ¾Û ½ ½, where the two numbers have identical bit representations, except that the argument is unsigned, while the result has a two’s complement representation. Conversely, the function Ì¾Í Û ´Üµ ¾Í Û ´Ì¾ Û ´Üµµ yields the unsigned number having the same bit representation as the two’s complement value of x. For example, as Figure 2.10 indicates, the 16-bit, two’s complement representation of 12,345 is identical to the 16-bit, unsigned representation of 53,191. Therefore Ì¾Í ½ ´ ½¾ ¿ µ ¿ ½ ½, and Í¾Ì ½ ´ ¿ ½ ½µ ½¾ ¿ . These two functions might seem purely of academic interest, but they actually have great practical importance. They formally deﬁne the effect of casting between signed and unsigned values in C. For example, consider executing the following code on a two’s complement machine: 1 2 int x = -1; unsigned ux = (unsi...
View Full Document

Ask a homework question - tutors are online