From d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:55:07 +0200 Subject: Add new code Signed-off-by: Carlos Maiolino --- CSAPP/chap2/2_12.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CSAPP/chap2/2_12.c (limited to 'CSAPP/chap2/2_12.c') 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 + +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; +} -- cgit v1.2.3