CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Sprintf and Float value booger....

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

Sprintf and Float value booger....
PostPosted: Fri May 05, 2006 12:47 pm     Reply with quote

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.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 05, 2006 2:00 pm     Reply with quote

I was able to get it to work with the "%7.5" format string.
Just the simple "%f" hasn't worked properly for awhile.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group