floor instead of ceiling for log2

562 Views Asked by At

A colleague and myself are working out the compression factor for dictionary compressions and we came accross this site, exploring binary, in the example of converting base 10 to base 2 numbers it recommends the use of floor instead of ceiling, $$bspec = ⌊\log_2(n)⌋ + 1$$

To quote the author, "You might be tempted to use the ceiling function — ⌈x⌉, which is the smallest integer greater than or equal to x — to compute the number of bits as such:"

$$bspec = ⌈\log_2(n)⌉$$

However, this fails when n is a power of two.

Could you explain how ceiling fails when n is power of two? And maybe from the perspective of people that are more accustomed to programming not math.