organization 4 4 16 32

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: mparison is also performed using an unsigned comparison, and since any 32-bit number is less than or equal to ÍÅ Ü ¿¾ , the comparison always holds! Thus, the code attempts to access invalid elements of array a. 696 APPENDIX B. SOLUTIONS TO PRACTICE PROBLEMS The code can be fixed by either declaring length to be an int, or by changing the test of the for loop to be i < length. Problem 2.17 Solution: [Pg. 56] This problem is a simple demonstration of arithmetic modulo 16. The easiest way to solve it is to convert the hex pattern into its unsigned decimal value. For nonzero values of Ü, we must have ´-u ܵ · Ü ½ . Then we convert the complemented value back to hex. Ü Hex 0 3 8 A F Problem 2.18 Solution: [Pg. 58] Decimal ¼ ¿ -u Decimal ¼ ½¿ Ü Hex 0 D 8 6 1 ½¼ ½ ½ This problem is an exercise to make sure you understand two’s complement addition. Ü Ý ½ ½ Ü·Ý ½½ ½ Ü +t Ý ¾ ¼¼½¼½ ¿¾ ¼ ¼¼¼¼¼ ½ Case 1 1 2 3 4 ½¼¼¼¼ ½¼½¼½ ½¼¼¼¼ ½¼¼¼¼ ½ ½½¼¼¼ ¾ ¼¼½½½ ¿ ¼¼½¼½ ½ ½½½½½ ¿ ¼¼¼½½ ½½½½¼ ½ ¼½¼...
View Full Document

Ask a homework question - tutors are online