Use bitwise operations for powers of two [#2282]

I am still working on benchmarks...