2022-12-05 07:01 AM
For example Unicode::snprintfFloat 70000.700f with "8.2f" incorrectly prints "70000.71", while snprintfFloat 60000.700 with "8.2f" correctly prints "60000.70"
Test code:
Unicode::snprintfFloat(textArea1Buffer, TEXTAREA1_SIZE, "%8.2f", 70000.700f);
Unicode::snprintfFloat(textArea2Buffer, TEXTAREA2_SIZE, "%8.2f", 60000.700f);
Output:
70000.71
60000.70
I can circumvent this by using regular snprintf() which prints this correctly, but any idea why this would print this example wrong? Unfortunately the snprintfFloat is closed-source function. Please fix.
2022-12-05 09:26 AM
i suppose, this is effect of rounding and "number representation" , decimal -> binary.
try: show full number, -> _SIZE, "%f ", 70000.700f ); (then we see, what number the cpu handels..)
2022-12-05 09:46 AM
@Romain DIELEMAN can you look at this, the float should be able to display 7 digits
snprintf() apparently works, but it might be using doubles internally.
Related
2022-12-16 07:08 AM
Hello Tuoman & Tesla DeLorean,
Thanks for reporting this, I reproduced the issue on my side, we're going to investigate on that.
/Osman
2023-01-03 06:23 AM
Hello Tuoman & Tesla DeLorean,
We have a patch ready for the next version of TouchGFX Designer (4.22.0)
Meanwhile as workaround I can suggest you to use normal snprintf to convert float to char string in a temporary buffer. Then use Unicode::strcpy or similar to convert to unicode.
/Osman