In Lua, using the type function on any number always returns 'number'. Is there a function which can tell you whether the Lua interpreter is using a 32 bit floats, 64 bit doubles, integers or something else for the number type?
I tried to write a function like this:
function numbertype()
local rational = 5 / 2
if rational == 2 then
-- equals 2
return 'int'
else
-- about 2.5
return 'double' -- but could it be a 32 bit float or something else?
end
end
print(numbertype())
It can't yet detect the difference between floats, doubles and unknown types. How can I query to see if Lua's number type is equivalent to an int, float or double in Lua's interpreter? I would like it to work in pure Lua.