2,875
edits
m (Add functions for parsing numbers) Tag: Reverted |
(Migrate numeric specific functions to Module:Number) Tag: Reverted |
||
Line 1: | Line 1: | ||
-- Module that contains all functions regarding numeric formatting and calculations. | |||
-- TODO: Make modules that now call Shared call Number (for relevant functions) | |||
local number = 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 | ||
--So rather than continue to copy across the same handful of functions to every single new module | --So rather than continue to copy across the same handful of functions to every single new module | ||
Line 165: | Line 169: | ||
--Adds commas | --Adds commas | ||
function p.formatnum(number) | function p.formatnum(number) | ||
return number.formatnum(number) | |||
end | end | ||
Line 187: | Line 178: | ||
function p.round(val, maxDigits, minDigits) | function p.round(val, maxDigits, minDigits) | ||
return number.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 number.round2(num, numDecimalPlaces) | |||
return | |||
end | end | ||
Line 310: | Line 277: | ||
-- Euclidean Greatest Common Divisor algorithm | -- Euclidean Greatest Common Divisor algorithm | ||
function p.gcd(a, b) | function p.gcd(a, b) | ||
return number.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 number.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 number.fractionpair(n, d) | |||
end | end | ||
Line 406: | 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 number.numStrWithSign(number) | |||
end | end | ||
Line 456: | Line 413: | ||
end | end | ||
return namespace, localID | return namespace, localID | ||
end | end | ||
return p | return p |
edits