Discussion about this post

User's avatar
skinpop's avatar

I prefer doubles in seconds to integers for game time.

* More readable for debugging. 1.16 seconds vs 1160000000 ns

* Your nanoseconds timers probably aren't as accurate as you think(depending on os, settings, hardware) and why do you need that precision to begin with?

* Doubles are more flexible. Since integers are fixed point you'll have to change a bunch of code if you suddenly decide that you'd rather work in microseconds or any other unit.

* More than enough precision for game time and animation. If changes in precision still worry you then just start your clock at 2^32 seconds - this will give your clock constant sub-microsecond precision for over a hundred years.

* You can use float32 for deltas as they have enough precision for any real use case involving game time. With nanosecond integers uint32 deltas will overflow after a few seconds.

That said, the most important thing is getting away from float32. Uint64 is a valid choice but I think doubles have meaningful advantages.

Expand full comment
1 more comment...

No posts