Calculate the number of digits in an integer.
I can't remember where I got this from, but it's proved very useful a few times:
int digits = (score == 0) ? 1 : (int)log10(score) + 1;
Written by Brian Hackett
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Integer
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#