Syntax
math.type(value); math.tointeger(value)Examples
Lua integer subtypes and conversion
Run with standalone Lua 5.4: lua example.lua. These scripts target Lua 5.4 rather than Roblox Luau.
print(math.type(7))
print(math.type(7.0))
print(math.tointeger(7.0))
print(math.tointeger(7.5) == nil)- Output: integer, float, 7, true. An integral float converts exactly; a fractional value cannot.
Best practices
- Use math.tointeger when conversion must be exact. Do not assume Luau implements Lua integer-subtype APIs.
Runtime & versions
Lua interpreter or a host application. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Lua reference manuals