We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Is there any library function in KEIL C which converts a floating point into string. If not can somebody give the appropriate code.
void float_to_char(char *total_str,float value){ int ipart=(int)value; //Extracting interger part only float fpart=value-(int)value; //Extracting floating value only int reversed=0; int i=0; char istring[100]; if(ipart==0) { istring[0]='0'; } else { while(ipart>0) { reversed=reversed*10 + ipart%10; //Reversing integer ipart=ipart/10; } } while(reversed>0) { istring[i]=reversed%10+'0'; //Adding digits to string array reversed=reversed/10; i++; } char fstring[100]; int k = 0; float x= fpart; fstring[k]='.'; //Adding . as decimal point k++; for(int j=0;j<6;j++) { x=x*10; fstring[k]='0'+(int)x; x=x-(int)x; k++; } int len = strlen(istring); //Length of integer string for(int i=0;i<100;i++) { if(istring[i]!='\0') { total_str[i]=istring[i]; //Grouping integer string and floating value string } else if(fstring[i]!='\0') { total_str[i]=fstring[i-len]; } }}