bitwise most significant set bit

后端 未结 10 2009
走了就别回头了
走了就别回头了 2020-12-20 19:50

I want to find the most significant bit that is set to 1. I have tried every possible way from & to ORing all of the bits from 1 t

10条回答
  •  难免孤独
    2020-12-20 20:05

    http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Integer.html#numberOfLeadingZeros%28int%29 You want something like 32 - Integer.numberOfLeadingZeros(value).

提交回复
热议问题