How to check if a number have integer representation
number can be a float or double
In Lua 5.3+, use math.tointeger:
math.tointeger (x) If the value x is convertible to an integer, returns that integer. Otherwise, returns nil.
math.tointeger (x)
If the value x is convertible to an integer, returns that integer. Otherwise, returns nil.