I was recently making a program which needed to check the number of digits in a number inputted by the user. As a result I made the following code:
int x;
int count = (x == 0) ? 1 : (int)(std::log10(std::abs((double)(x)))))) + 1;