GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Index
  • std.debug
  • std.io
  • std.package
  • std.string
  • std.table
  • std
  • table

This view

  • Original page
  • New address

GeezerVison is showing lua-stdlib.github.io — stdlib Reference


stdlib

  • Index

Contents

  • Core Functions
  • Deprecated Functions

Core Libraries

  • std.debug
  • std.io
  • std.math
  • std.package
  • std.string
  • std.table

Core Functions

  • std

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'

Core Functions

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

Deprecated Functions

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


Core Functions

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

Parameters:

  • n number number
  • p integer number of decimal places to truncate to (default 0)

Returns:

    number n truncated to p decimal places

Usage:

    tenths = floor(magnitude, 1)
round (n[, p=0])
Round a number to a given number of decimal places.

Parameters:

  • n number number
  • p integer number of decimal places to round to (default 0)

Returns:

    number n rounded to p decimal places

Usage:

    roughly = round(exactly, 2)

Deprecated Functions

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()
generated by LDoc 1.5.0 Last updated 2026-10-22 19:02:37
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.