I'm going to assume (perhaps wrongly) that this isn't a troll.
Aren't the bitshift operators pointless?
a << b is the same as a = a * 2^b;
I think you meant "a <<= b".
a >> b is the same as a = a % 2^b;
I think you meant "a >>= b" and "a = a / 2^b".
Except that the ^ operator doesn't appear to do what you think: it's not
exponentiation, it's an exclusive-or operator.
I've run some tests and the bitshift operators aren't any faster than
their equivalent math expressions.
I wonder what that code looks like? Did you test the results that came
back?
When I run a quick million-cycle test of these two, the second method
using Math.pow gives takes about ten times as long to run. This makes
sense, given the complexity of the code involved. For a sample, see:
http://www.devdaily.com/scw/c/cygwin/src/winsup/mingw/mingwex/math/pow.c.shtml
Implementation of bit-shift operators, on the other hand, is usually as
simple as a single machine instruction.
Note that the expansions you give only work with a subset of the domain
values. For instance, -1 >> 1 == -1 not 0.