Determining the number of iterations needed to find the number of bits in an integer
The number of bits is always an integer, so you have to solve for that equation over the integers.  Thus, use $\lceil \lg (n+1) \rceil$.