AnsweredAssumed Answered

printf float format like "%0.02f" does not work

Question asked by Sandro Bastos on Aug 31, 2015
Latest reply on Sep 23, 2015 by Kai Falkenberg

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

 

Rene Kolarik

Karina Valencia Aguilar

Bruno Castelucci

Outcomes