求小数的位数
double dec = 0.63;dec *= 10;
for(i = 0;(int)dec != 0;i++)
{
dec -= (int)dec;
dec *= 10;
}
printf("%d",i);
#include<stdio.h> int main() { double dec = 5550.636254; int i=0; while(1) { dec=dec-int(dec); if(dec*10-int(dec*10)<0.0000001) break; i++; dec=dec*10; } i++; printf("%d",i); return 0; }也有些BUG 期待高手解答