AnsweredAssumed Answered

PRINTF support for Scientific Notation, "e" specifier in KSDK 2.0

Question asked by Mark Sample on Aug 26, 2016
Latest reply on Aug 29, 2016 by Mark Sample

Hello,

How do you get the "e" specifier to work with PRINTF in KSDK 2.0? Using IAR. 

 

For example, this code:

#include "fsl_debug_console.h"

#define PRINTF DbgConsole_Printf

float a_float_number = 123456.78;
PRINTF(" a_float_number = %e\n", a_float_number);
PRINTF(" a_float_number = %f\n", a_float_number);

 

generates this output:

 

a_float_number = e
a_float_number = 123456.781250

 

The same code works as expected in a KDSK 1.3 project with lower case printf. This is the output with KDSK 1.3:

 

a_float_number = 1.234568e+05
a_float_number = 123456.781250

 

I put #include <stdio.h> in the file but this made no difference. 

 

Maybe it is just not supported. The e specifere is not listed in the Kinetis SDK v.2.0 API Reference Manual in section 12.1.2 Advanced Feature. However, the e specifier is mentioned when discussing the # flag "Used with e, E and f, it forces the written output to contain a decimal point even if no digits would follow."

 

If e is not supported maybe it could be added next rev.

 

Any help would be greatly appreciated!

 

Thanks,

Mark

Outcomes