Module:Utils/doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
m nowiki
m Update intro
Line 1: Line 1:
This module provides several mathematical functions which are likely to be used frequently on the Xenharmonic Wiki.
This module provides several mathematical functions which are likely to be used frequently on the Xenharmonic Wiki.


Namely, the functions in these modules can be called from other modules using the <code>require('Module:xyz')</code> function.
Namely, the functions in this module can be called from other modules using <code>require('Module:Utils')</code> and the <code>_</code>-prefixed functions.


== Functions ==
== Functions ==

Revision as of 06:16, 19 August 2022

This module provides several mathematical functions which are likely to be used frequently on the Xenharmonic Wiki.

Namely, the functions in this module can be called from other modules using require('Module:Utils') and the _-prefixed functions.

Functions

  • eval_num_arg(input, def_value) checks if input is a number; on error, use def_value. This function is designed to be used by other modules only; it cannot be called with {{#invoke:}}.
  • log(x, b) returns the logarithm base b of x. Parameter b defaults to base 2 (octave) if it is omitted.
  • round(x, prec) returns x rounded to a precision of prec decimal places. Parameter prec defaults to 3 if it is omitted.