CString str = _T("362.15");
int n1=str.Find(L".");
int n2=str.GetLength()-n1-1;
str=str.Left(n1)+str.Mid(n1+1);
float temp1 = _tstof(str);
temp1=temp1/pow(10.0,n2);我以为上面这种笨方法可以的,结果36215/100.0,一样变为了362.14999。看来无解了。用double也不行。
int n1=str.Find(L".");
int n2=str.GetLength()-n1-1;
str=str.Left(n1)+str.Mid(n1+1);
float temp1 = _tstof(str);
temp1=temp1/pow(10.0,n2);我以为上面这种笨方法可以的,结果36215/100.0,一样变为了362.14999。看来无解了。用double也不行。
直接赋值后,你调试发现f的值也是362.14999。float里面根本就无法表达362.15这个数值。