Jump to content

Module:NumberAbbr: Difference between revisions

MisterChuChu (talk | contribs)
No edit summary
MisterChuChu (talk | contribs)
Remove commas from number
Line 2: Line 2:
function p.abbr(frame)
function p.abbr(frame)
local f=frame
local f=frame
local n=f.args[1]~=nil and tostring(f.args[1]) or "0" --number to abbreviate
local n=f.args[1]~=nil and string.gsub(f.args[1],",","") or "0" --number to abbreviate
local dec=f.args[2]~=nil and math.min(math.max(f.args[2],0),11) or 3 --decimal places
local dec=f.args[2]~=nil and math.min(math.max(f.args[2],0),11) or 3 --decimal places
local s=f.args[3]~=nil and math.max(f.args[3],3) or 6 --start at 10^
local s=f.args[3]~=nil and math.max(f.args[3],3) or 6 --start at 10^
local abt=f.args[4]==nil and false or f.args[4] --use abbr tag?
local abt=f.args[4]==nil and false or f.args[4] --use abbr tag?
if tonumber(f.args[1])==nil then --cancel abbreviation if number is invalid
if tonumber(n)==nil then --cancel abbreviation if number is invalid
return f.args[1]
return f.args[1]
else
else
Cookies help us deliver our services. By using our services, you agree to our use of cookies.