Although the same mask can be written 0xffffffff for

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: a type, that is, one declared as type char or int, with or without qualifiers such as short, long, or unsigned. Here are some example expression evaluations: C Expression ˜0x41 ˜0x00 0x69 & 0x55 0x69 | 0x55 Binary Expression ˜ ¼½¼¼¼¼¼½ ˜ ¼¼¼¼¼¼¼¼ ¼½½¼½¼¼½ & ¼½¼½¼½¼½ ¼½½¼½¼¼½ | ¼½¼½¼½¼½ Binary Result ½¼½½½½½¼ ½½½½½½½½ ¼½¼¼¼¼¼½ ¼½½½½½¼½ C Result 0xBE 0xFF 0x41 0x7D As our examples show, the best way to determine the effect of a bit-level expression is to expand the hexadecimal arguments to their binary representations, perform the operations in binary, and then convert back to hexadecimal. Practice Problem 2.6: To show how the ring properties of ˆ can be useful, consider the following program: 1 2 3 void inplace_swap(int *x, int *y) { *x = *x ˆ *y; /* Step 1 */ 38 4 5 6 CHAPTER 2. REPRESENTING AND MANIPULATING INFORMATION *y = *x ˆ *y; *x = *x ˆ *y; } /* Step 2 */ /* Step 3 */ As the name implies, we...
View Full Document

Ask a homework question - tutors are online