# [ solved ]Break down two digits, to one Digit.

I am using this clock function on LCD Display [lcd.print(now.minutes (), DEC);], When this compute and spits out on the serial line of the Arduino the line reads 15. I want to use if statement and read to two digits together or just the Single digit. Is there a way I can do digit trap with Arduino. So it can read the 15 or just the 5 Data.

``````[lcd.print(now.minutes(), DEC);] = 15

//( this if statement all I want to do is read the two digits 15 )
If ((lcd.print(now.minutes(), DEC) =< 10)
{
Do this
}

[lcd.print(now.minutes(), DEC);] = 05

//( this if statement all I want to do is read the one digit 5 )
If ((lcd.print(now.minutes(), DEC) =< 5)
{
Do this
}
[\code]
``````

15 % 10 == 5 15 / 10 % 10 == 1

Additional hint: what you print is the result of the function call `now.minutes()` which returns most likely a `uint8_t` --> that's a number.

then you can apply what @MarkT is suggesting

should be faster than division via lookup table but code size will be bigger or if else for smaller code size without division. only for 2 digit decimals.

``````unsigned char number=0;
unsigned char second_number=0;
unsigned char first_number=0;

second_number = number % 10;
number -= second_number;

switch (number) {

case 10: case 20: case 30:
first_number = number >> 3;
break;
case 40:
first_number = number - 1 >> 3;
break;
case 50:
first_number = number - 10 >> 3;
break;
default:
first_number = number - 11 >> 3;
break;
}
``````

MarkT and J-M-L both your solutions worked excellent thank you for the time and the data.