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 CCS Technical Support

Float to string

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



Joined: 20 Apr 2004
Posts: 2

View user's profile Send private message

Float to string
PostPosted: Tue May 10, 2005 3:24 pm     Reply with quote

I'm looking for a float to string like that in sprintf, except I want to be able to place the format string in a ram buffer. Any thoughts?
Ttelmah
Guest







PostPosted: Tue May 10, 2005 3:39 pm     Reply with quote

Unfortunately, the answer will be 'write your own'. Be prepared for just how large this will become though. The 'reason' the standard command is limited to a constant string, is that this allows a lot of the code to be omitted from the used version. A 'general purpose' float to string, with variables as inputs, will be _big_...
There are some printf code examples on the web, which could be modified, but if you don't need the full abilities of a printf, then a much simpler conversion could be used. For instance, I did one that just allowed the number of displayed digits to be set in a variable. This was relatively simple to do, just involving outputing the value digit by digit using a division, adding a decimal point when the remainder when fractional, and stopping after the variable number of digits.

Best Wishes
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