math.huge is a constant in lua that represents the float value HUGE_VAL, which is greater than any other numeric value.

Syntax

math.huge

Return value

The value of math.huge is a positive infinity.

Description

math.huge is a special constant that is used to represent positive infinity. It can be utilized in mathematical calculations to signify an unbounded upper limit.

Examples

Using math.huge

print(math.huge)               -- inf
print(math.huge + 1)           -- inf
print(math.huge * 2)           -- inf
print(1 / math.huge)           -- 0
print(math.huge == math.huge)  -- true

See also

  • math.isinf(x)
    Checks if x is positive or negative infinity.

  • math.isnan(x)
    Checks if x is NaN (not a number).

  • math.abs(x)
    Returns the absolute value of x.

Was this page helpful?

Table of Contents