This reminds me of an assignment we had in one of my CpE classes. We had to implement a whole bunch of interesting operations using a limited set of operators and in as few operations as possible. Favorites:
Absolute value of a signed it:
a= x >> 32
return (a + x)^a
Swap values of two ints without a temporary int:
a^=b
b^=a
a^=b
! operator (boolean not) without any boolean operators:
int a = x | (~x +1);
int b = a >> 31;
return b + 1;
There were a ton of interesting problems. Made for a great assignment.