k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
Perhaps, instead of using a loop, you could calculate j by calculate how many times the loop will run? (instead of actually doing it) This case looks a bit tricky, but it might be possible.
Something simpler:
nn = 1;
for (i=0;i<m;i++)
nn *= 2;[code]This loop will run m times, each time multiplying nn with 2. So nn will end up being 2^m. So you could either do "nn = pow( 2, m )" or "nn = 1 << m;" depending on what is fastest, avoiding a loop completely.
doing such things I'm afraid I will corrupt the code.
But I expect for and while loops to be as stable and as fast enough just as they are. So I actually don't want to change them.