16,472
社区成员
发帖
与我相关
我的任务
分享
float f=5.02;
float f2=(f*100);
double d=f2;
float a = 5.02;
int b = (int)(a*100);
// 测试的代码
float a = 5.02;
float b = a * 100;
unsigned int c = a * 100;
unsigned int d = b;
unsigned int e = (UINT)(float)(a * 100);
TRACE( _T("a:%f, b:%f, c:%d, d:%d, e:%d \n"), a, b, c, d, e );
// 打印的结果
// a:5.020000, b:502.000000, c:501, d:502, e:501
// 确实有点奇怪,原因不大清楚,等待高人来解答。不过可以按照d的那种方式来计算就可以得到正确的值。
float a = 5.02f;
a *= 100;
CString str;
str.Format(_T("%lf"), a);
AfxMessageBox(str);
unsigned short t=setdj.InputDJ*(float)100;