Replace uses of floating point log2 when we want an integer result from an integer operand. This avoids concerns about accuracy of floating point library functions.