double 小数点位数截取

double setDoublePrecision(double dInDate, int iPrecision = 4)
{
    char buf[512] = {0};
	char szPrecision[32] = {0};
    sprintf(szPrecision, "%s%df", "%.", iPrecision);
    sprintf(buf, szPrecision, dInDate);

    return atof(buf);
}

  

posted @ 2018-06-07 15:16  那一剑的風情  阅读(803)  评论(0)    收藏  举报