Books are the ladder of human progress. Before I read the fourth edition of Lua Programming, I didn't know that Lua has divisor operators. When I need to return the divisor result, I have to perform extra operations to subtract the decimal part. A few days ago, the demand just needed to divide and take the integer part of a floating point number, use it, and make this record.
Divide
" / " in Lua stands for division, and the calculation results are all decimals. Lua5.3 also provides an even division operator " // ".
Take integer
The lua math library provides three rounding functions
math.floor(),math.ceil()和math.modf()
math.floor() rounds towards negative infinity
math.ceil() obtains evidence from positive infinity
modf rounds to zero (there are two return values, the integer and the decimal part are returned)