Hi Rene,
https://community.freescale.com/message/560857?et=watches.email.thread#560857
18 months later this discussion, another float format problem was found.
I'm still using MQX 4.1.1, with the corrections discussed in this post.
I'm using the float format "%0.02f" to obtain outputs of type "x.yz".
1- If the number is, for example, 1.234, I get "1.23" ---> that's right.
2- If the number is shorter than one and greater than 0.1, for example, 0.123, the output string is "012" (without dot) and not "0.12".
3- If the number is shorter than 0.1, e.g. 0.05, it also works giving an "0.05" string.
Resuming, the wrong result is for the range: 0.1 <= x < 1.0
Another workaround or correction I could apply?
thank you,
sandro
Hello Sandro,
On MQX for Kinetis when I try:
float pi = 3.1415;
printf("The Pi number is: %2.2f\n",pi);
printf("And a tenth of Pi is: %2.2f\n",pi/10);
I got on the terminal:
The Pi number is: 3.14
And a tenth of Pi is: 0.31
Can you make a test trying to use %1.2f instead?
Hi Denis,
I've just run your example and got a wrong output (the same for "%2.2f" and "%1.2f"):
The Pi number is: 3.14
And a tenth of Pi is: 031
Remember I'm using a patched MQX4.1.1 (see the link at the top of this post); maybe the patches are causing this problem.
thank you and best regards,
sandro
Hi Rene,
the old bug, cited in the top link of this post, is still present in MQX 4.2 :(
so we have to apply that patches that brings this new bad behavior.
regards,
sandro