I have a project that I am working on that I'm using the ADC on a PIC18F45K22 with a thermistor. I am converting the ADC output to degrees but I need to convert a double to an ascii string.
I am using MPLab IDE with xc8 compiler. It has itoa the library but no file to do what I need.
Why not use itoa anyway? Get the integer part, convert it and then subtract from double before multiplying the double by 1000 and get 4 decimal places by converting to int again.
Or, if your temp can't go above 650°C then multiply by 100 and use itoa to convert and insert decimal point as appropriate.
Or, better still use 8.8 variables and keep it all in integers.
Mike.
Edit, some code I wrote for integers in the form nn.nnn (Your double * 1000 cast to int)
Code:
void Put8(unsigned int num){
//buf in the form nn.nnn, as largest is 65.535
unsigned char buf[7],i,j;
itoa(buf,num,10);
i=0;
while(buf[i]!=0)
i++;
j=6;
while(i!=255) //move to end of buffer
buf[j--]=buf[i--];
while(j!=255)
buf[j--]='0'; //pad with zeroes
buf[0]=buf[1]; //shuffle
buf[1]=buf[2]; //to make room for decimal
buf[2]='.'; //insert decimal
for(i=0;i<6;i++)
Output(buf[i]);
}