char *F2S(double d, char *str) {
char str1[40];
int j = 0;
int k, i;
i = (int)d; // 浮点数的整数部分
while (i > 0) {
str1[j++] = i % 10 + ‘0‘;
i /= 10;
}
for (k = 0; k < j; ++k) {
str[k] = str[j - 1 - k];
str[j++] = ‘.‘;
for (i = 0; i < 10; ++i) {
d *= 10;
str[j++] = (int)d + ‘0‘;
d -= (int)d;
}
}
while (str[--j] == ‘0‘) {
str[++j] = ‘\0‘;
return str;
}
}
时间: 2024-11-05 14:51:45