# Module `std.math`

Additions to the core math module.

The module table returned by `std.math` also contains all of the entries from the core math table. An hygienic way to import this module, then, is simply to override the core `math` locally:

    local math = require "std.math"

## Functions

floor (n[, p=0]) | Extend `math.floor` to take the number of decimal places.
monkey_patch ([namespace=_G]) | Overwrite core `math` methods with `std` enhanced versions.
round (n[, p=0]) | Round a number to a given number of decimal places

## Functions

Methods

floor (n[, p=0])
  Extend `math.floor` to take the number of decimal places.

  ### Parameters:

  - n number number
  - p int number of decimal places to truncate to (default 0)

  ### Returns:

  number `n` truncated to `p` decimal places

  ### Usage:

      tenths = floor (magnitude, 1)

monkey_patch ([namespace=_G])
  Overwrite core `math` methods with `std` enhanced versions.

  ### Parameters:

  - namespace table where to install global functions (default _G)

  ### Returns:

  table the module table

  ### Usage:

      require "std.math".monkey_patch ()

round (n[, p=0])
  Round a number to a given number of decimal places

  ### Parameters:

  - n number number
  - p int number of decimal places to round to (default 0)

  ### Returns:

  number `n` rounded to `p` decimal places

  ### Usage:

      roughly = round (exactly, 2)

generated by LDoc 1.4.3 Last updated 2018-09-03 17:48:42