math.huge
Shared
A constant representing positive infinity
Constant
math.huge -- infRepresents positive infinity. Useful as a sentinel initial value for minimum-finding loops, or for comparisons involving unbounded ranges.
Examples
engine.print("info", math.huge) -- infengine.print("info", math.huge > 1e308) -- trueengine.print("info", -math.huge < -1e308) -- truelocal values = {42, 7, 99, 3, 56}
local smallest = math.huge
for _, v in ipairs(values) do
if v < smallest then
smallest = v
end
end
engine.print("info", smallest) -- 3local values = {42, 7, 99, 3, 56}
local largest = -math.huge
for _, v in ipairs(values) do
if v > largest then
largest = v
end
end
engine.print("info", largest) -- 99local function is_finite(value)
return value > -math.huge and value < math.huge
end
engine.print("info", is_finite(42)) -- true
engine.print("info", is_finite(math.huge)) -- falselocal result = 1 / 0
engine.print("info", result == math.huge) -- true