Check out example codes for "c how many digits has a number". It will help you in understanding the concepts better.

Code Example 1

digits = (number == 0) ? 1 : (log10(number) + 1);
//or
while (number > 0)
{
	number /= 10;
	digits++;
}
//see: https://ideone.com/P1h8Ne

Learn ReactJs, React Native from akashmittal.com