I'm trying to break down an integer with C on an 8-bit microcontroller (a PIC) into its ASCII equivalent characters.
For example: convert 982 to '9','8','2'
Everything I've come up with so far seems pretty brute force. This is the main idea of what I'm basically doing right now:
if( (10 <= n) && (n < 100) ) {
// isolate and update the first order of magnitude
digit_0 = (n % 10);
// isolate and update the second order of magnitude
switch( n - (n % 10) ) {
case 0:
digit_1 = 0;
break;
case 10:
digit_1 = 1;
break;
...
And then I have another function to just add 0b00110000 (48decimal) to each of my digits.
I've been having trouble finding any C function to do this for me or doing it well myself.
Thanks in advance for any help!