其具有一段代碼,林wrinting應用,在那裏T->蜱是浮動:浮點數和usleep問題
usleep(1000);
t->tick = t->tick + 0.001;
printf("tick is %f, firing time is %f\n", t->tick, t->firing_time);
我發現有在usleep?:
tick is 0.313000, firing time is 2.000000
tick is 0.314000, firing time is 2.000000
tick is 0.314999, firing time is 2.000000
tick is 0.315999, firing time is 2.000000
錯誤如何擺脫那個錯誤?
如何計算'firing_time'? – 2011-06-14 12:33:18
是float並設置爲2.000000 – JosiP 2011-06-14 12:33:45
http://floating-point-gui.de/ – 2011-06-14 12:34:30