The Arduino IDE(compiler)'s float bug

1.通常直接使用串口的print函数就ok
Serial.println(DHT.humidity);  //assuming DHT.humidity is float

2.但是习惯问题,还是偏好sprintf,则可以考虑dtostrf
dtostrf(DHT.humidity,3,0,rh);
参数1为float值。
参数2转换后整数部分长度
参数3为float精确度,如1则为保留1位。
参数4为转换后的字符串。

 

修正于:http://www.lixin.me/blog/2013/04/21/29713

 

 

posted on 2013-10-08 22:32  新一  阅读(298)  评论(0编辑  收藏  举报

导航