|
|
Rockbox mail archiveSubject: Optimizing to functions for a pluginOptimizing to functions for a plugin
From: Joseph Garvin <k04jg02_at_gmail.com>
Date: Wed, 15 Oct 2008 13:09:47 -0500
There don't appear to be any builtin functions for converting strings
static unsigned long string_to_long(const char* toConvert)
for(i = 0; i < rb->strlen(toConvert) - 1; ++i)
for(c = toConvert; *c != '\0'; ++c) {
return result;
static float string_to_float(const char* toConvert)
for(c = toConvert; *c != '.'; ++c)
rb->memcpy(convert_buffer, toConvert, decimal_location);
result = string_to_long(convert_buffer);
rb->strcpy(convert_buffer, toConvert + decimal_location + 1);
decimal_places = rb->strlen(toConvert) - decimal_location - 1;
for(i = 0; i < decimal_places; ++i)
result += (double)string_to_long(convert_buffer) / (double)pow_of_10;
return (float)result;
Page was last modified "Jan 10 2012" The Rockbox Crew |