Rockbox Development > Starting Development and Compiling

No float/double output in snprintf on Sansa e200V1 hardware

(1/2) > >>

DB1BMN:
Hello,

I am messing a little bit in source code.
I've extended the moonrock-patch, which calculates some moon data. The calculation and output on simulator seems to be correct, but if I compile for hardware, the output of double values with %f-tag in snprintf is corrupted and I see only the placeholder f on the screen.
Any Ideas?


--- Code: ---
struct tm tm_utc;    // time values struct
double utc_offset=1.0;    // shift of local time wrt. UTC

rb->snprintf(output,sizeof(output), "UTC: %02d:%02d:%02d %+2.1fh", tm_utc.tm_hour, tm_utc.tm_min, tm_utc.tm_sec, utc_offset );
rb->lcd_puts(0, 0,output);

--- End code ---

The formatted output of the integers with 2 digits and leading zeros by %02d works, but double output of %+2.1f doesn't :-(

Another

Kindly Regards, Mark

torne:
Our printf doesn't support floats. The simulator uses the platform version on some platforms, so it may work there.

saratoga:
The e200v1 doesn't have a floating point unit.  Actually only the Gigabeat S has an FPU, and its (currently) disabled in Rockbox to save power. 

DB1BMN:
Good evening and thanks for the light-speed answers!
Ok, and how to overcome or workaround that?
The Sansa performs at the moment some kind of double-calculations, because the moon-results (julian date with fractions ect.) ar correct so far. So how to print fraction numbers?

Regards, Mark

saratoga:

--- Quote from: DB1BMN on January 02, 2010, 07:08:59 PM ---The Sansa performs at the moment some kind of double-calculations, because the moon-results (julian date with fractions ect.) ar correct so far. So how to print fraction numbers?

--- End quote ---

Presumably gcc is emulating those floating point operations using integer instructions.  I would cast the integer and fractional parts of your number to ints (after scaling the latter so that it casts to non-zero), and print them as "%d.%d".

Navigation

[0] Message Index

[#] Next page

Go to full version