float a = 0.01;
float b = 1;
int c = (int)(a*100);//我watch等号右边的值是1没错,那就是我想要的
结果c=0;
float a = 0.02;
float b = 1;
int c = (int)(a*100);//我watch等号右边的值是2没错,那就是我想要的
结果c=1
float b = 1;
int c = (int)(a*100);//我watch等号右边的值是1没错,那就是我想要的
结果c=0;
float a = 0.02;
float b = 1;
int c = (int)(a*100);//我watch等号右边的值是2没错,那就是我想要的
结果c=1
int c = (int)floor(a*100);//
int c = (int)(a*100 + 1e-10 );其中1e-10改成你所允许的精度。
你float-->int 类型转换错误,转换总是朝表达数据能力强的方向进行。
我想取任意一个float数的小数点后的2位值,比如1.234,我要值1.230
有没有这样的库函数?如果没有该怎么做?