可能重複:
Is there a function to round a float in C or do I need to write my own?如何在用C語言打印時舍入類型浮點變量?
之前我造成任何混亂......這是我使用什麼C++
cout.setf(ios::fixed);
..
cout.precision(3);
..
我用圓所有打印數字在C++中保留3位小數。我無法在C中工作。任何幫助?
可能重複:
Is there a function to round a float in C or do I need to write my own?如何在用C語言打印時舍入類型浮點變量?
之前我造成任何混亂......這是我使用什麼C++
cout.setf(ios::fixed);
..
cout.precision(3);
..
我用圓所有打印數字在C++中保留3位小數。我無法在C中工作。任何幫助?
這樣做:
printf("%0.3f", myFloat);
http://stackoverflow.co m/questions/497018/is-there-a-function-to-round-a-float-in-c-or-do-i-need-to-write-my-own這是重複的。請關閉。 – mydogisbox