Unformatted text preview: ne. Problem 2.8 Solution: [Pg. 38] These problems help you think about the relation between Boolean operations and typical masking operations. Here is the code:
/* Bit Set */ int bis(int x, int m) { int result = x  m; return result; } /* Bit Clear */ int bic(int x, int m) { int result = x & ˜m; return result; } It is easy to see that bis is equivalent to Boolean O R—a bit is set in z if either this bit is set in x or it is set in m. The bic operation is a bit more subtle. We want to set a bit of z to 0 if the corresponding bit of m equals 1. If we complement the mask giving ˜m, then we want to set a bit of z to 0 if the corresponding bit of the complemented mask equals 0. We can do this with the A ND operation. Problem 2.9 Solution: [Pg. 39] This problem highlights the relation between bitlevel Boolean operations and logic operations in C. 694 Expression x&y xy ˜x  ˜y x & !y Problem 2.10 Solution: [Pg. 40] The expression is !(x ˆ y). APPENDIX B. SOLUTIONS TO PRACTICE PROBLEMS
Value 0x02 0xF7 0xFD 0x00 Expression x && y x  y !x  !y x &am...
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.
 Spring '10
 Schultz
 The American, Gulliver's Travels, 2.2.5 2.2.6 2.2.7 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5

Click to edit the document details