This is what I have right now, any idea how to improve this code? Speed is of no importance since it only executes once in the program.
The solution must not include any extra libraries, since I'm trying to keep the executable small.
/** Returns the most significant bit set in a value.
*/
static FORCEINLINE unsigned int mostSignificantBitSet(unsigned int value)
{
unsigned int result = 0;
while (value != 0) {
++result;
value >>= 1;
}
return result-1;
}