There is one, but it's not public :) It's spelled _binaryLogarithm() + 1
and it's available on BinaryInteger
.
(For reasons beyond the scope of our discussion here, _binaryLogarithm()
is generally more useful than _binaryLogarithm() + 1
.)
The method is probably useful enough that it could pass the bar for becoming a public API, but I dread the bikeshedding and haven't proposed it. For end users, though, it's not really more convenient than bitWidth - leadingZeroBitCount
.