69,336
社区成员
发帖
与我相关
我的任务
分享
float f=1.234f;
char s[20];
char *p;
int L;
sprintf(s,"%g",f);
p=strchr(s,'.');
if (NULL==p) L=0;
else {
L=strlen(s)-(p-s)-1;
switch (p[1]) {
case '0':printf(".0\n");break;
case '5':printf(".5\n");break;
default:printf("not .0 and not .5\n");break;
}
}