Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted

Works well, thanks TK!

Oh, and if negative numbers are possible use:

MIOS32_MIDI_SendDebugMessage("%d.%03d\n", (int)value, abs((int)(1000*value)%1000));

otherwise you get a negative symbol appearing in the fraction part.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...