Simpler method:

Take input into a string. Convert that string into a number. Then number of digits is log(number)+1.

Just to clarify, this is log with base 10. I'm not sure if the log function in cmath evaluates log base 10, log base 2, or natural log (log base e). To make sure, use log(number)/log(desired base). No matter what base the log function is, dividing by log(desired base) results in the same answer as a log to the correct base of number.