Okay so I am developing a server for my game, and a fairly common thing is to keep track of time, for cooldowns, movement and etc. Now, this seems simple enough, you have either golangs time package or you can use ticks to calculate the time. I tried the second approach, which would work perfectly if not for the fact that float64 is not exactly 0.2 but rather something like 0.199999999999999998, which throws off the calculations. Actually, there is no easy way that I found to calculate seconds in decimals, eg. if the server ticks 5 times a second, it would be 0.2s, 0.4s, 0.6sâ€¦ 1s, 1.2sâ€¦ Iâ€™ve been thinking of using 200 instead of 0.2 and just go with that, but I hate scaling everything by 1000 in the game just for calculations to work. These time calculations and checks would be happening all the time so I cannot overengineer something or hack it up.

How do you guys go about it, Iâ€™ve been tackling this problem for a while and honestly would love to hear someoneâ€™s take on this? (pseudo code or code is greatly appreciated!)