1,048
edits
(Migrate numeric specific functions to Module:Number) Tag: Reverted |
(Fix name clash between parameters and module name) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
-- Module that contains all functions regarding numeric formatting and calculations. | -- Module that contains all functions regarding numeric formatting and calculations. | ||
-- TODO: Make modules that now call Shared call Number (for relevant functions) | -- TODO: Make modules that now call Shared call Number (for relevant functions) | ||
local | local numModule = require('Module:Number') | ||
--So there are a handful of functions that I'm using in a lot of places | --So there are a handful of functions that I'm using in a lot of places | ||
Line 169: | Line 169: | ||
--Adds commas | --Adds commas | ||
function p.formatnum(number) | function p.formatnum(number) | ||
return | return numModule.formatnum(number) | ||
end | end | ||
Line 178: | Line 178: | ||
function p.round(val, maxDigits, minDigits) | function p.round(val, maxDigits, minDigits) | ||
return | return numModule.round(val, maxDigits, minDigits) | ||
end | end | ||
--From http://lua-users.org/wiki/SimpleRound | --From http://lua-users.org/wiki/SimpleRound | ||
function p.round2(num, numDecimalPlaces) | function p.round2(num, numDecimalPlaces) | ||
return | return numModule.round2(num, numDecimalPlaces) | ||
end | end | ||
Line 277: | Line 277: | ||
-- Euclidean Greatest Common Divisor algorithm | -- Euclidean Greatest Common Divisor algorithm | ||
function p.gcd(a, b) | function p.gcd(a, b) | ||
return | return numModule.gcd(a, b) | ||
end | end | ||
--Formats a pair of numbers as a reduced fraction | --Formats a pair of numbers as a reduced fraction | ||
function p.fraction(n, d) | function p.fraction(n, d) | ||
return | return numModule.fraction(n, d) | ||
end | end | ||
--Similar to p.fraction but returns the simplified numerator and denomerator separately without formatting | --Similar to p.fraction but returns the simplified numerator and denomerator separately without formatting | ||
function p.fractionpair(n, d) | function p.fractionpair(n, d) | ||
return | return numModule.fractionpair(n, d) | ||
end | end | ||
Line 367: | Line 367: | ||
--Returns a number including the sign, even if positive | --Returns a number including the sign, even if positive | ||
function p.numStrWithSign(number) | function p.numStrWithSign(number) | ||
return | return numModule.numStrWithSign(number) | ||
end | end | ||
edits