esp-open-sdk
esp-open-sdk copied to clipboard
printf and snprintf does not work for float or double variable
When i use "snprintf" in my program on freeRTOS, i find it does not work properly. So i tried to print the float variable out to check the problem.
printf("temperature: %f\n", 22.5);
But i got these below.
temperature:
Is it due to the toolchain? What can i do to solve this problem? Much appreciated.
You need to do something like this.
float temperature = 22.5; int t = temperature*10; printf("temperature: %d.%d\n", t/10, t%10);