summaryrefslogtreecommitdiff
path: root/CSAPP/chap2/2_12.c
diff options
context:
space:
mode:
Diffstat (limited to 'CSAPP/chap2/2_12.c')
-rw-r--r--CSAPP/chap2/2_12.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/CSAPP/chap2/2_12.c b/CSAPP/chap2/2_12.c
new file mode 100644
index 0000000..b7f53ac
--- /dev/null
+++ b/CSAPP/chap2/2_12.c
@@ -0,0 +1,12 @@
+#include <stdio.h>
+
+int main (void) {
+ int a = 0x87654321;
+
+ printf("Ans A: 0x%.8x\n", (a & 0xff));
+ printf("Ans B: 0x%.8x\n", ((~a) & ((~0) & ~0xff)) | (a & 0xff));
+ printf("Ans B2: 0x%.8x\n", ((~0xff) & (~a)) |(a & 0xff));
+ printf("Ans C: 0x%.8x\n", (a | 0xff));
+
+ return 0;
+}