2021-09-27 04:59 AM
Hi,
I try to display a float with a precision of 9 number after the digit. My wildcard buffer size is set to 20.
Unicode::snprintfFloat(textArea1Buffer, TEXTAREA1_SIZE, "%.9f", 0.123456789f);
textArea1.invalidate();
My output when running the simulator is the following: 0.123457
Is the snprintfFloat format limited to 6 digits ?
I'm using TouchGFX Designer 4.17.0.
Thanks
Solved! Go to Solution.
2021-09-28 12:54 AM
In the mean time I cast into an array this way all the digits are printed
char array[20];
sprintf(array, "%.9f", 0.123456789f);
Unicode::strncpy(textArea1Buffer, array, TEXTAREA1_SIZE);
textArea1.invalidate();
2021-09-27 05:48 AM
Note that the precision of a 32-bit float itself is limited to about 6 digits. Printing more digits than that may be misleading.
2021-09-27 06:09 AM
This is strange because if I place myself in debug mode with a float number = 0.123456789f, I see that all the digits are kept, despite using 32-bit float
2021-09-28 12:54 AM
In the mean time I cast into an array this way all the digits are printed
char array[20];
sprintf(array, "%.9f", 0.123456789f);
Unicode::strncpy(textArea1Buffer, array, TEXTAREA1_SIZE);
textArea1.invalidate();