Also, counting digits in base 2 is not the log2. The former gives you the latter but not the reverse. Finding the number of decimal digits in a number given in base 2 is not a simplification.
...and then checks for and corrects the potential off-by-one thus incurred.
If you do these calculations by hand, the complexity will be more obvious because each operation will be smaller.