logically checking range of number of digits in a number