Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  No float/double output in snprintf on Sansa e200V1 hardware
« previous next »
  • Print
Pages: [1]

Author Topic: No float/double output in snprintf on Sansa e200V1 hardware  (Read 1974 times)

Offline DB1BMN

  • Member
  • *
  • Posts: 14
  • Sansa e250 V1; Ubuntu 9.04
No float/double output in snprintf on Sansa e200V1 hardware
« on: January 02, 2010, 06:54:24 PM »
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: [Select]

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);

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
Logged

Offline torne

  • Developer
  • Member
  • *
  • Posts: 994
  • arf arf
Re: No float/double output in snprintf on Sansa e200V1 hardware
« Reply #1 on: January 02, 2010, 06:59:59 PM »
Our printf doesn't support floats. The simulator uses the platform version on some platforms, so it may work there.
Logged
some kind of ARM guy. ipodvideo/gigabeat-s/h120/clipv2. to save time let's assume i know everything.

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: No float/double output in snprintf on Sansa e200V1 hardware
« Reply #2 on: January 02, 2010, 07:02:50 PM »
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. 

Logged

Offline DB1BMN

  • Member
  • *
  • Posts: 14
  • Sansa e250 V1; Ubuntu 9.04
Re: No float/double output in snprintf on Sansa e200V1 hardware
« Reply #3 on: January 02, 2010, 07:08:59 PM »
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
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: No float/double output in snprintf on Sansa e200V1 hardware
« Reply #4 on: January 02, 2010, 07:13:01 PM »
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?

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".
Logged

Offline DB1BMN

  • Member
  • *
  • Posts: 14
  • Sansa e250 V1; Ubuntu 9.04
Re: No float/double output in snprintf on Sansa e200V1 hardware
« Reply #5 on: January 03, 2010, 06:31:52 AM »
Good Morning,

ok thank you!
I think I will write some kind of a double_2_string(.)-function, so I can print it with %s.

Regards, Mark
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  No float/double output in snprintf on Sansa e200V1 hardware
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.074 seconds with 15 queries.