Jump to content

full featured sprintf() formatter?


Duggle
 Share

Recommended Posts

I need to display floating point variables as I am experimenting with sensors of different kinds.

I find sprintf() is not formatting float types.

Is there a switch somewhere that controls the compile of stdio.h functions to include a full featured string formatter library?

Also is floating point math fully supported by default?

thanks

Link to comment
Share on other sites

Floating point math is fully supported (libm is included)

But you don't really want to use the original printf() routine - it requires liba for functions like _read, _write, _sbrk, etc... and as far as I remember, later it will ask for libos as well.

Thats unnecessary overhead (+ some implementation effort for the missing functions).

If you want to try to get it running: disable all functions in http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fmios32%2Fcommon%2Fprintf-stdarg.c

Alternatively add the code for %f to the print() replacement

Or just do the conversion in your application, e.g.:


MIOS32_MIDI_SendDebugMessage("%d.%03d\n", (int)value, (int)(1000*value)%1000);
[/code]

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...