Is there an algorithm to absolutely determine the number of digits the decimal form of an integer will have?
Example:
1,234 has 4 digits in decimal
It is easy to count the number manually, but this is useless when the number is given in binary or another base, without converting.
Example:
The binary number 10011010010 has 4 decimal digits
The hexadecimal number 4D2 has 4 decimal digits
So, given an integer, is there an algorithm that will determine the number of decimal digits it takes to represent?
This should be a mathematical manipulation, not converting to a character array in a programming languages and counting the size of the array.
Tags: