Joseph Garvin wrote:
There don't appear to be any builtin functions for converting strings
to floats or longs, so I wrote a couple, but they're very very rough.
We use sscanf() for that in Rockbox, but it doesn't support floats,
since we don't use floating point calculations in this project.
On 16.10.2008, Linus Nielsen Feltzing wrote:
Joseph Garvin wrote:
There don't appear to be any builtin functions for converting
strings to floats or longs, so I wrote a couple, but they're
very very rough.
We use sscanf() for that in Rockbox, but it doesn't support
floats, since we don't
Jens Arnold wrote:
There is no sscanf() in the rockbox core, because its more
advanced features aren't needed. sscanf.c does exist in
firmware/common, but is only compiled and linked to doom.
In the core we use atoi().
There's also the string to fixed-point conversion in replaygain.c.
There don't appear to be any builtin functions for converting strings
to floats or longs, so I wrote a couple, but they're very very rough.
I care less about precision than about speed. Anybody have tips on how
to speed them up?
static unsigned long string_to_long(const char* toConvert)
{
static unsigned long string_to_long(const char* toConvert)
{
unsigned long result = 0;
const char* c;
unsigned int i;
unsigned long pow_of_10 = 1;
for(c = toConvert[ rb-strlen(toConvert)-1]; c != toConvert; --c) {
result += char_to_long(*c) * pow_of_10;