Skip to main content
evgeny_sazhaev
Visitor II
November 23, 2012
Question

STM32F3, IAR6.4 how to printf() floating point?

  • November 23, 2012
  • 2 replies
  • 1003 views
Posted on November 23, 2012 at 05:08

Or, in general, how to printf() numbers with decimal point?

Thanks

#floating-point---just-say-no
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    November 23, 2012
    Posted on November 23, 2012 at 05:37

    Pretty much the same as any other C compiler. With IAR you'd need to link against a suitable library with the level of support you need.

    ''Choosing formatters for printf and scanf'' might be worth a review

    http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Andrew Neil
    Super User
    November 23, 2012
    Posted on November 23, 2012 at 09:54

    ''With IAR you'd need to link against a suitable library with the level of support you need''

    And similarly for other embedded toolsets.

    Using floating-point brings very large burdens in terms of execution speed and code size - which is why most embedded toolsets will not enable floating-point support unless you specifically request it.

    Many (most?) calculations in embedded systems can be done perfectly well - and at vastly reduced overhead - with integer arithmetic and a little thought. Or, perhaps, with fixed-point.

    So a more fundamental question migth be: why do you feel the need for floating point...?

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.