Module optmath

Simple math helper functions

Functions

Math.roundPercent (percent) Rounds a percentage.
Math.roundAwayFromZero (num) Rounds away from zero.
Math.round (num) Rounds a number.
Math.oddEven (number) Determines if a number is odd or even.
Math.tmin (tab, func) Returns the minimum element of a table.
Math.tmax (tab, func) Returns the maximum element of a table.


Functions

Math.roundPercent (percent)
Rounds a percentage.

Parameters:

  • percent float

Returns:

    int rounded percentage
Math.roundAwayFromZero (num)
Rounds away from zero.

Parameters:

  • num float

Returns:

    int ceiled above 0, floored under 0
Math.round (num)
Rounds a number. No support for decimal points.

Parameters:

  • num float

Returns:

    int rounded number
Math.oddEven (number)
Determines if a number is odd or even.

Parameters:

  • number int

Returns:

    string "odd" or "even"
Math.tmin (tab, func)
Returns the minimum element of a table. The optional argument func specifies a one-argument ordering function.

Parameters:

Returns:

    dynamic minimum element of a table
Math.tmax (tab, func)
Returns the maximum element of a table. The optional argument func specifies a one-argument ordering function.

Parameters:

Returns:

    dynamic maximum element of a table
generated by LDoc 1.4.6 Last updated 2020-07-05 22:54:19