0miker0
1
How can I get break up and integer to get the 100ths or 1000value?
int t= 1234
int a = t % 10; //get units
//I see a value on the serial monitor of 4
x = x/10;
int b = t % 10; // get tens value
//I see a value on the serial monitor of 3
How can I see the 2 and the 1?
Mike
0miker0:
How can I see the 2 and the 1?
You mean: "t = t/10;"
t = t/10;
int c = t % 10; // get hundreds value
t = t/10;
int d = t % 10; // get thousands value
Alternatively:
int ones = t%10;
int tens = (t/10)%10;
int hundreds = (t/100)%10;
int thousands = (t/1000)%10;
I prefer the last solution of John as it keeps the original value of t