string str;
int nLastZero = strfmt.find_last_of('0'); //最后一个0的位置
string unit = strfmt.substr(nLastZero+1); //单位
int decplace = strfmt.find('.'); //小数点的位置
int commaplace = strfmt.find(','); //整句的位置
if( decplace == -1 ) //没有小数点
{
ostringstream out;
out << value;
if( commaplace == -1 )
str = out.str();
else //有逗号
str = FormatComma( out.str(), nLastZero - commaplace);
str += unit;
return str;
}//endif 没有小数点的情况
//格式字符串中有小数点的情况
int declen = strfmt.substr(decplace, nLastZero - decplace).size() - 1;
__int64 intPart = value / div; //整数部分
__int64 decPart = value % div; //小数部分
for( int i = 0; i < declen; ++i)
decPart = decPart * 10;
decPart = decPart / div;
ostringstream out;
int prec = std::numeric_limits<long double>::digits10;
out.precision(prec);
out << intPart << ".";
if ( decPart == 0 )
{
string zeros(declen, '0');
out << zeros;
}
else
out << decPart;
str = out.str();
if( commaplace != -1 )
str = FormatComma( out.str(), decplace - commaplace - 1);
str += unit;
return str;