int length = (int) (Math.log10(number) + 1);
int n = 1000; int length = (int)(Math.log10(n)+1); //NB: only valid for n > 0