quote:
I recommend this way, although log(10) is 1, so you can safely ignore the dividing part.
Nope. log(10) is 2.3. log is the natural logarithm. But I agree this is the best way. Assumes n is an integer and larger than one though.
quote:
floor(log(n)/log(10)) + 1
Or ceil(log(n)/log(10)).