Getting the number of characters in an int

Is there an easy way to get the number of characters in an integer number -
at the moment I am doing

if (x<10){length=1;
}else{
if (x<100{length=2;
}else{

etc.....

but this seems really clunky - is there a simpler way?

Cheers

Nick

You could do something like:

int length = 1;

while (x >= 10) {
  length++;
  x /= 10;
}

Spot on, thanks.