Powers of Four in C# 17 Sep 2010
I recently implemented a function in C# to check if an unsigned integer is a power of four as a part of my new game and I wanted to share two possible implementations. The first relies on the fact that a power of four (1) has only a single bit set and (2) has an even number of zero bits after the one.
For 32-bit unsigned integers we can employ some bit manipulation to acheive the same effect, by checking that we have a power of two that is also a power of four.