等效于De Bruijn LSB,但适用于MSB [英] Equivalent of De Bruijn LSB, but for MSB
本文介绍了等效于De Bruijn LSB,但适用于MSB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
除了MSB之外,有人知道类似于De Bruijn的LSB的算法吗?或者是确定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?
我知道Log_2(Val)将执行此操作,但是我不知道这是否是最有效的方法.
I know Log_2(Val) will do this, but I don't know if it's the most efficient method.
我需要它的原因是我需要将little-endian转换为big-endian.我知道这个的标准算法.但是,输入是64位,但通常数字是16或24位,因此不需要99.9%的时间交换整个8个字节.
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.