324_Book

# 324_Book

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: eight Two’s Complement Original Truncated ¼ ¼ ¿ ¼ ¿ ½ ¾ ½ As Equation 2.7 states, the effect of this truncation on unsigned values is to simply to ﬁnd their residue, modulo 8. The effect of the truncation on signed values is a bit more complex. According to Equation 2.8, we ﬁrst compute the modulo 8 residue of the argument. This will give values ¼– for arguments ¼– , and also for arguments – ½. Then we apply function Í¾Ì ¿ to these residues, giving two repetitions of the sequences ¼–¿ and – ½. Problem 2.16 Solution: [Pg. 52] This problem was designed to demonstrate how easily bugs can arise due to the implicit casting from signed to unsigned. It seems quite natural to pass parameter length as an unsigned, since one would never want to use a negative length. The stopping criterion i <= length-1 also seems quite natural. But combining these two yields an unexpected outcome! Since parameter length is unsigned, the computation ¼ ½ is performed using unsigned arithmetic, which is equivalent to modular addition. The result is then ÍÅ Ü ¿¾ (assuming a 32-bit machine). The co...
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