|
|
View previous topic :: View next topic |
Author |
Message |
mjscott
Joined: 20 Apr 2004 Posts: 2
|
Float to string |
Posted: Tue May 10, 2005 3:24 pm |
|
|
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
|
|
Posted: Tue May 10, 2005 3:39 pm |
|
|
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 |
|
|
|
|
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
|