float serialization
Created by: alex9x
Hi! Please, help with float serialization.
Function to cut one decimal and part of code: ` float Round1(float tmp) { return ((int)(tmp * 10)) / 10.0; }
DynamicJsonBuffer jsonBuffer(200); JsonObject& log = jsonBuffer.createObject(); tmp_t=24.35141; // float value from sensor log["dht_t"] = Round1(tmp_t); // cut to one decimal ` got results in log file:
{"dht_t":24} {"dht_t":24.1} {"dht_t":24.2} {"dht_t":24.29999} - for 24.3 {"dht_t":24.4} {"dht_t":24.5} {"dht_t":24.6} {"dht_t":24.7} {"dht_t":24.79999} - for 24.8 {"dht_t":24.9}
problem with x.3 and x.8
Any help are welcome!