c++中如何只保留float型的小数点后两位?

来源:互联网 发布:mac os 刷新dns 编辑:程序博客网 时间:2024/06/05 17:11

round(x * 100) / 100.0


Or:


float ff = 36.51647;
ff = ( (float)( (int)( (ff + 0.005) * 100 ) ) ) / 100;


1 Error 放大(km),再 / 1000

2 精度 放大(m),再 / 1000