Came across this conditional in some uncommented Objective-C code:
if (w & (w - 1))
{
i = 1;
while (i < w)
{
i *= 2;
}
w = i;
}
Where w is a size_t greater than 1.
Update: Added the code contained by the conditional for context.
It tests whether more than one bit is set in
w, i.e. whether it’s not an exact power of two. See here.