Equivalent of De Bruijn LSB, but for MSB
问题 Does anyone know of an algorithm similar to De Bruijn's LSB, but for MSB? Or alternately the most efficient way of determining the MSB? I know Log_2(Val) will do this, but I don't know if it's the most efficient method. The reason I need it is I need to convert little-endian to big-endian. I know the standard algorithm for this. However, the input is 64 bit, but typically the numbers will be 16 or 24 bit, so swapping the whole 8 bytes around is unneeded 99.9% of the time. 回答1: Isn't this