luaguides

Reference

Math Functions

Mathematical functions.

  1. math.abs

    `math.abs` returns the absolute value of a number in Lua 5.4. Preserves the integer/float subtype, handles math.mininteger safely, coerces numeric strings.

  2. math.ceil

    math.ceil rounds a number up to the smallest integer greater than or equal to it in Lua 5.4, with notes on integer/float subtypes and negative values.

  3. math.floor

    Round a number down to the largest integer less than or equal to it, with integer-vs-float return behavior in Lua 5.4.

  4. math.max

    math.max returns the largest of two or more numbers in Lua 5.4, with integer and float subtype rules, type coercion, and edge-case behavior.

  5. math.min

    math.min returns the smallest of one or more numeric arguments in Lua 5.4. Covers syntax, return type, NaN behavior, infinity, and zero-arg errors.