Match tick count max value in Lua5.1?

Hello everyone. I have a question about the tick value of the match_loop’s tick value.

match_loop(context, dispatcher, tick, state, messages)

If I check the Lua documentation, it is a number. In lua 5.1, according to chatGPT, the max value of a number is 2^53 − 1 = 9007199254740991. But in the Go documentation, it is a 64-bit integer, so the max value is 2^63 - 1 = 9223372036854775807.

To sum up, what should I expect as the max value? What is the situation with this problem?

I’m asking because I’m creating tick-count-based logic on the server side. If the maximum value is exceeded by default, it will automatically start from the minimum value. What should I expect after, if the value exceeds 2^53 − 1 = 9007199254740991 ???

Hello @yusuf

10_000 (years) * 365 (days) * 24 (hours) * 60 (minutes) * 60 (seconds) * 60 (ticks/s) < (2^53) − 1

Unless my math is off, even with the lower max value the tick in a long-running match with the highest allowed ticks/s of 60 wouldn’t rollover for at least 10_000 years, so I don’t think that should be a concern :slight_smile: .

But if you’re using very big numbers from within the Lua VM, you should either experiment with a test or refer to GitHub - yuin/gopher-lua: GopherLua: VM and compiler for Lua in Go to understand what the actual limit is.

I’d expect it to comply with the Lua 5.1 spec, but I am not certain myself.

Best.

1 Like