Hi ledsarecool,ledsarecool wrote: When the temperature is 21.00 or 21.10 or 21.20 ect.
It will only show the first digit after the decimal point.
How can i print 1 decimal place also?
To display a single decimal place instead of two decimal places, replace this line:
Code: Select all
snprintf(str2_buf, 20, "%d.%d" , (int)t, (int)(t*100)-(int)t*100); // string with degree C
Code: Select all
snprintf(str2_buf, 20, "%d.%d" , (int)t, (int)(t*10)-(int)t*10); // string with degree C