最近遇到float 转换为int 的问题,先上个例子:
#include "main.h"
int
main()
{
float
a = 1.30;
float
b = 1.30;
int
x,y;
float
tmp;
tmp = (a*100);
x = (
int
)tmp;
y = (
int
)(b*100);
cout<<x<<endl;
cout<<y<<endl;
return
0;
}
输出结果为:
130
129
实际项目中的代码: