Royce Mitchell III schrieb:
  I managed to shave off another comparison in favor of
a shift: 
What about using a 64k table?
static
BYTE HighestBits[65536] = {
 0x00, 0x01, 0x02, 0x02, ... // and so on
};
// returns 0xFF when no bits set in dwValue
BYTE highest_bit(DWORD dwValue)
{
  BYTE ret;
  if (i > 0xffff) {
    ret = HighestBits[(int) (dwValue >> 16)];
  } else {
    ret = HighestBits[(int) dwValue];
  }
  return ret - 1;
}
Regards,
Mark