bit manipulation - Equivalent of De Bruijn LSB, but for MSB -


Is anyone aware of algorithms similar to the D. Bruge's LSB, but for MSB? Alternatively, what is the most effective method of determining MSB?

I know Log_2 (val) will do this, but I do not know that this is the most effective way.

Because I need that I need to convert a little-endian into big-endian. I know standard algorithms for this. However, input is 64 bits, but usually numbers will be 16 or 24 bits, so swaping the entire 8 bytes is 99.9% of the time unnecessary.

Is not it at all?

Comments