2017-06-12 11:51 PM
Hello,
I am working on a firmware for the STM32F765.
This MCU was chosen because of its double precision floating point capabilities.I manged to configure the FPU/Compiler (ARM GCC 5.4) to genertate correct DP native assembly instructions.When debugging, I can verify correct DP calculations.The only thing I cannot manage is to printf results in double precision.
I have tried the formatters %f and %lf but on every printf only single precision is printed out (correctly rounded results but with too less digits).I am using newlib speed optimized (NOT nano), but also the lib stdc++ does the same.Has somebody ever seen the printf output in double precision for an embedded ARM Cortex-M7 code with GCC & if yes, how do I get it running ?Thank you in advance,
GahlenSolved! Go to Solution.
2017-06-13 01:02 AM
I have tried the formatters %f and %lf but on every printf only single precision is printed out (correctly rounded results but with too less digits).
Take a look at the POSIX spec. of the
printf()
style functions (e.g. the Linux manpages).For the e,f and g format, it states '...if the precision is missing, it is taken as 6;'.
Try, for example, '%.10lf'
2017-06-13 01:02 AM
I have tried the formatters %f and %lf but on every printf only single precision is printed out (correctly rounded results but with too less digits).
Take a look at the POSIX spec. of the
printf()
style functions (e.g. the Linux manpages).For the e,f and g format, it states '...if the precision is missing, it is taken as 6;'.
Try, for example, '%.10lf'
2017-06-13 02:03 AM
'man fprintf' on my Linux system tells to use '%Lf' or '%llf' for long double arguments.
2017-06-13 03:33 AM
Thank you very much! I did not know this, but exactly this was needed to print out the required precision.
2017-06-13 04:39 AM
I just want to print out 64bit double values with many fractional digits. These have the printf formatters %f or %lf.
What you mean with %Lf or %llf is 128bit quad precision that the Cortec-M7 cannot handle natively.
2017-06-13 04:58 AM
And I'm pretty sure most scanf/printf implementations (libraries) for Cortex M cannot handle long double types.
2017-06-13 10:29 AM
>>
This MCU was chosen because of its double precision floating point capabilities.
I've never understood the use case for the single precision one....
Glad it was just a format issue, the default will be misleading, I tend to prefer specifying a very large number of decimal place, and using the '%le' variant.
Unfortunately the FPU designs of recent years don't hold intermediate values at higher precision, and this is compounded by the availability of only simpler intrinsic functions.
2017-06-14 04:33 AM
I've never understood the use case for the single precision one....
I am 100% with you... what shall we do with just 7 decimal digits precision? -> single precision is just to have FP in the specs
I tend to prefer specifying a very large number of decimal place
unfortunately most programmers are not scientists at all; the current default value of 6 fractional digits is confusing in this situation because it let me thought that the output was single precision only
Unfortunately the FPU designs of recent years don't hold intermediate values at higher precision
I was a little bit disappointed when I read that the Cortex-M DP FPU has 64bit only, even for the internal intermediate values; I can remember that in the late 80s Motorola's FPUs already applied extended precision for intermediate representations...
this is compounded by the availability of only simpler intrinsic functions
I would be glad just to have native DP sin and cos functions for DQ transformations...
2017-06-14 05:18 AM
I assume three reasons:
2017-06-14 07:30 AM