Module:Shared: Difference between revisions

Fix name clash between parameters and module name
(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 number = require('Module:Number')
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 number.formatnum(number)
return numModule.formatnum(number)
end
end


Line 178: Line 178:


function p.round(val, maxDigits, minDigits)
function p.round(val, maxDigits, minDigits)
return number.round(val, maxDigits, minDigits)
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 number.round2(num, numDecimalPlaces)
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 number.gcd(a, b)
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 number.fraction(n, d)
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 number.fractionpair(n, d)
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 number.numStrWithSign(number)
return numModule.numStrWithSign(number)
end
end


915

edits