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)) -- 4All lessons in this course
- math Library Functions
- table Library Functions
- os and io Libraries
- The debug Library