17 lines
543 B
C
17 lines
543 B
C
/* Count the number of digits an integer has */
|
|
unsigned long long intDigitCount(unsigned long long in) {
|
|
unsigned long long largestDigit;
|
|
int digitCount = 0;
|
|
for (largestDigit = 1; in / largestDigit != 0; largestDigit *= 10)
|
|
++digitCount;
|
|
return digitCount;
|
|
}
|
|
|
|
/* Expand an integer into an integer whose first unit is 1 followed by a leading trail of 0's*/
|
|
unsigned long long intDigitExpand(unsigned long long in) {
|
|
int expandedDigit;
|
|
for (expandedDigit = 1; in != 1; --in)
|
|
expandedDigit *= 10;
|
|
return expandedDigit;
|
|
}
|