```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 ``` ```/* more bit hacks */ #include int main(void) { int x, y; /* 1) Compute the minimum (or maximum) of two integers without branching */ x = 37; y = 84; printf("%d\n", y ^ ((x ^ y) & -(x < y))); // min printf("%d\n", x ^ ((x ^ y) & -(x < y))); // max x = 84; y = 37; printf("%d\n", y ^ ((x ^ y) & -(x < y))); // min printf("%d\n", x ^ ((x ^ y) & -(x < y))); // max printf("\n"); /* 2) Determine if an integer is a power of two */ x = 37; printf("%d\n", (x & (x - 1)) == 0); x = 32; printf("%d\n", (x & (x - 1)) == 0); x = 0; printf("%d\n", (x & (x - 1)) == 0); x = 37; printf("%d\n", x && !(x & (x - 1))); x = 32; printf("%d\n", x && !(x & (x - 1))); x = 0; printf("%d\n", x && !(x & (x - 1))); printf("\n"); /* 3) Swap the values of two variables */ #define SWAP(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) x = 37; y = 84; SWAP(x, y); printf("%d %d\n", x, y); #define SWAP(a, b) (((a) -= (b)), ((b) += (a)), ((a) = (b) - (a))) x = 37; y = 84; SWAP(x, y); printf("%d %d\n", x, y); return 0; } ```
 ```1 2 3 4 5 6 7 8 9 10 11 12 13 14 ``` ```37 84 37 84 0 1 1 0 1 0 84 37 84 37 ```