ljbeng
Joined: 10 Feb 2004 Posts: 205
|
Sprintf and Float value booger.... |
Posted: Fri May 05, 2006 12:47 pm |
|
|
These are the only few lines (of significance) in my test program. I just wanted to test how I can get a float to copy to a string. This seems wrong to me.... V3.249. 18f2620.
Code: |
char datstring[20];
float real;
.
.
.
while(1){
real = 11110.333;
sprintf(datstring,"%f",real);
}
|
datstring = "-1774.56846"
Code: |
real = 11110.333;
sprintf(datstring,"%10.3f",real);
|
datstring = " 11110.333"
I am datalogging data from another source that comes to me from the serial port in ieee format. I use f_IEEEtoPIC to convert to PIC float format but I don't want to limit the log printout to a specified format (%10.3f) I just want the PIC to convert from ieee to float to string and print....whatever the value. |
|