我想找到设置为 1
的最高有效位。我已经尝试了所有可能的方法,从 &
到对从 1
到 31
的所有位进行 ORing,但它不起作用。
如果 1000000
我想要 7
。
最佳答案
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Integer.html#numberOfLeadingZeros%28int%29
你想要像 32 - Integer.numberOfLeadingZeros(value)
这样的东西。
关于java - 按位最高有效位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9117793/