Should this be `31 - Integer.numberOfLeadingZeros(v)` if you want `floor(log2(x))` ? If you want `ceil(log2(x))` then I think you want `32 - Integer.numberOfLeadingZeros(v - 1)`