7 and 28 apply to these cases 227 advice on signed vs

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: %d:\t", x); show_bytes((byte_pointer) &x, sizeof(int)); printf("ux = %u:\t", ux); show_bytes((byte_pointer) &ux, sizeof(unsigned)); When run on a 32-bit, big-endian machine using two’s complement representations this code prints: sx usx x ux = = = = -12345: 53191: -12345: 53191: cf cf ff 00 c7 c7 ff cf c7 00 cf c7 50 CHAPTER 2. REPRESENTING AND MANIPULATING INFORMATION We see that although the two’s complement representation of 12,345 and the unsigned representation of 53,191 are identical for a 16-bit word size, they differ for a 32-bit word size. In particular, 12,345 has hexadecimal representation 0xFFFFCFC7, while 53,191 has hexadecimal representation 0x0000CFC7. The former has been sign-extended—16 copies of the most significant bit 1, having hexadecimal representation 0xFFFF, have been added as leading bits. The latter has been extended with 16 leading 0s, having hexadecimal representation 0x0000. Can we justify that sign extension works? What we want to prove is that ¾Ì Û· ´ Ü ½ Û Ü...
View Full Document

Ask a homework question - tutors are online