Ted Gress wrote:
I'm trying to create a Profiler. One of the thing sit uses is time elapsed. Go I've been using Java's getNano time method. However, I"m getting floating point overflow. What can I do about it ?
Stephan van Hulst wrote:Keep in mind that doubles don't overflow. If you have a double variable with a positive finite starting value and you keep adding to it or multiplying it with a finite positive amount, eventually it will reach Double.MAX_VALUE, and stay there. If the value you add or multiply it with is small enough, it won't even ever reach Double.MAX_VALUE, instead settling at a lesser value.
Never write == false or == true, which are both bad style and error‑prone.
It is not obvious how you are getting the frametime variable from line 6 into the rest of the code. It is also not obvious how you are getting values from that infinite loop into the rest of the code. What is more, if you have that infinite loop, are you setting the start time in line 4 after you have set the finishing time in line 22?
Ted Gress wrote:
Is the issue is at time_frame_ratio, it is doing floating point division. time_Frame_ratio is the only value that is coming back negative.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |