int yourInt = 12345;
X = yourInt / 10;
Y = yourInt - (X * 10);
okay, same answer was given above but this is a more literal interpretation.
By the way, I did some testing comparing modulo with brute force successive subtraction, modulo lost, I think 5 or 8 times slower IIRC. But math speed depends so much on which processor is running it. Also even a single instruction multiply instruction puts a CPU at a huge advantage for a lot of things. You can go on from there, but that basic enhancement is a big one. I think integer divide is not possible or isn't feasible, I don't know which, in a single machine cycle. I know the hardware behind multiplication, it's easy to see how it can be done a lot in parallel. But the AVR is a tiny RISC with addition and subtraction only. That's one reason why you see a lot of the new Arduinos come with more advanced CPU's.
Thanks for this info. Because I'm using cooperative multitasking in this project, I certainly don't want to waste any cycles. How do you balance the speed improvement of removing the modulo against the costs associated with creating and using another variable? The time to write a line to the LCD is on the order of 5ms anyway. Then again, if the performance increase significant, there's no reason not to make this substitution standard practice, shaving off microseconds wherever possible. The math is simple enough that it doesn't impair readability.
For anyone else using a method like this, I just want to point out that in order to support negative numbers, you need the absolute value of Y so you don't get a result like "-1234.-5".
It's also true that everything ends of as a string eventually, if you're going to display it. It's far beyond my skill level to try to compare forming a string and printing it to giving print the integer and letting it figure out the details (+10 Overloads? Is that bad? It sounds bad.) Here's what I have currently:
snprintf( lineFour, 21, "Target: %4d.%1d lbs ", targetWeight/10, abs(targetWeight%10) );
lcd.print( lineFour );
Now that I think of it, I should probably only overwrite the value and not re-print "Target:" every time...