0Pricing
Lua Academy · Lesson

math Library Functions

Use math.floor, ceil, sqrt, sin, cos, random, huge, and pi.

The math Module

The math module provides mathematical constants and functions: math.pi, math.huge, math.maxinteger, and dozens of functions.

Rounding Functions

math.floor rounds down, math.ceil rounds up, math.tointeger converts a float to integer or returns nil.

print(math.floor(3.7))       -- 3
print(math.ceil(3.2))         -- 4
print(math.tointeger(4.0))    -- 4

All lessons in this course

  1. math Library Functions
  2. table Library Functions
  3. os and io Libraries
  4. The debug Library
← Back to Lua Academy