char* GetDoubleStr(double value) { char buf[32]={0};//长度可以自定义 sprintf(buf,"%.8f",value);//保留8位小数,不够补0 int index = 0; int len = strlen(buf); for(int i = len-1;i>0;i--) { if(buf[i] == ‘0‘) continue; else { if(buf[i] == ‘.‘) index = i; else index = i+1; break; } } buf[index] = ‘\0‘; return buf; }
时间: 2024-10-27 11:45:06