Unsigned case is: return (x & -x) > (x - 1); Wouldn't this be better: return (sz & (sz-1)) == 0; I also don't understand the integer promotion and recursive call in the integer case. Can someone explain how the std.math implementation is ideal?