Skip to main content
philipgillespie
Associate
April 21, 2011
Question

How to use floating point with printf

  • April 21, 2011
  • 2 replies
  • 645 views
Posted on April 21, 2011 at 13:40

How to use floating point with printf

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

    2 replies

    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 14:32

    Since Floating Point requires very significantly more resources (memory space, execution time, etc) than integer maths - especially on a chip like the STM32 with no hardware FPU - it is often best avoided on (small) microcontrollers.

    For this reason, many (most?) embedded toolsets disable floating point by default.

    Therefore, the first thing you really need to ask yourself is, ''do I really need floating point?''

     

     

    eg, instead of 

    float volts;

    volts = 1.6483; you could have:

    int millivolts;

    millivolts = 16483;

    Otherwise, you are going to have to consult your Raisonance manuals to find out about their support 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.
    Andrew Neil
    Super User
    May 17, 2011
    Posted on May 17, 2011 at 14:32

    Floating point also raises a number of issues about precision...

    Take a look at, for example: 

    http://www.guidogybels.eu/fpart1.html

    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.