The math.mininteger constant represents the minimum value that can be stored in an integer type in lua.

Syntax

math.mininteger

Return value

Returns the minimum integer value, typically represented as a constant. This value is implementation-dependent but is guaranteed to be at least -(2^53 - 1) for systems that use double-precision floating-point numbers to represent integers.

Description

math.mininteger is a predefined constant in lua that signifies the smallest integer that can be safely represented without loss of precision. It is particularly useful for performing arithmetic operations that involve small integers to ensure that they do not exceed the representable range.

Examples

Using math.mininteger

print(math.mininteger)                -- Output: -9223372036854775808 (or the equivalent minimum integer value)

Comparison with other integers

local smallNumber = math.mininteger - 1
print(smallNumber)                     -- Output may vary, could result in a number that cannot be represented as an integer
print(smallNumber == math.mininteger - 1) -- false, as it exceeds mininteger

See also

  • math.min()
  • math.max()
  • math.maxinteger

Was this page helpful?

Table of Contents