int highbit(int a) { int prev, curr; prev = a; curr = a; while(curr) { prev = curr; curr &= prev - 1; } return prev; }