unsigned int deltaTime = now() - last();
unsigned int freq = getFreq();
float timeOfGap = float(deltaTime) / float(freq);
ASSERT(0.0f <= timeOfGap, "WHAT?");
I got a really weired result from my program. I didn't catch a scene which is happened. But I have a log which said that really raised at least multiple times.
There are possible way of dividing between two float numbers which was casted from unsigned int make negative float result?
OK, thank you guys. I'm glad to see your attentions. Let me try to add some descriptions about it. It'll be helpful for you.
I'm working for an online game, and this situation was raised rarely but frequently while hundreds of million times game was serving. I can't debug or catch the exact shot, but it is logged on the db error messages.
The timeOfGap should be NaN as you noticed, but the log didn't alert the value exactly. The timeOfGap is accumulated like below;
mTotalFrameRateTimeAsASecond += timeOfGap;
And this program logs mTotalFrameRateTimeAsASecond, that was a negative value. But except this sign of value was a negative, it is correct value. Meaning, it point time as look as good if I divide the final value with a framerate. A hypothetical play time was 500 sec, it is -30000(with 60 framerate per sec).
Maybe it is not negative, but a NAN. 0.0f <= NAN is false. It may happen if both operands are zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With