unsigned int deltaTime = now() - last();
unsigned int freq = getFreq();
float timeOfGap = float(deltaTime) / float(freq);
ASSERT(0.0f <= timeOfGap, "WHAT?");
I got an excellent result from my program. I did not catch the scene that happened. But I have a magazine that says it’s really raised at least a few times.
Is there a possible way of dividing two floating point numbers that were cast from an unsigned int that makes the float negative?
Ok, thanks guys. I am glad to see your attention. Let me try to add some descriptions. It will be useful for you.
I am working on an online game, and this situation rarely occurred, but often when I played hundreds of millions of times. I cannot debug or catch the exact snapshot, but it is written to the db error messages.
TimeOfGap should be NaN, as you noticed, but the log did not return a value exactly. TimeOfGap accumulates as shown below:
mTotalFrameRateTimeAsASecond += timeOfGap;
And this program registers mTotalFrameRateTimeAsASecond, which is a negative value. But besides the fact that this attribute of value was negative, it is the correct value. Meaning, this is a point in time, as well, if I share the final value with the frame rate. The hypothetical playback time was 500 seconds, it was -30000 (with a frequency of 60 frames per second).
source
share