0
我用Java數學有問題。我有以下表現:用浮點數和雙精度計算的
double tripp = (timeNow-previousTime)/(seconds*Sys.getTimerResolution())*trip;
當我試圖計算我的立方體的旋轉速度。這裏是我的完整的代碼功能,我這樣做:
public float getTripLenghtToGo(int seconds, double trip) {
long timeNow = Sys.getTime();
System.out.println("RES: "+Sys.getTimerResolution());
double tripp = (timeNow-previousTime)/(seconds*Sys.getTimerResolution())*trip;
System.out.println("("+timeNow+"-"+previousTime+")/("+seconds+"*"+Sys.getTimerResolution()+")*"+trip+" = "+tripp);
if(tripp != 0){
previousTime = timeNow;
}
return (float)tripp;
}
我使用OpenGL所以它必須返回浮動。它返回浮點數,但始終爲零。
你能提供你的調試輸出語句的輸出嗎? – flyx 2013-04-06 17:09:29