double su = 6.8;
Serial.println(round(su));
Serial.println(int(su));
Serial.println(trunc(su));
运行结果:
int()取整是忽略小数位
round()取整是按照四舍五入
double su = 6.8;
Serial.println(round(su));
Serial.println(int(su));
Serial.println(trunc(su));
运行结果:
int()取整是忽略小数位
round()取整是按照四舍五入