-- This implements {{change}}localp={}localfunctionntsh(outvalue)localsortkey='0000000000000000000'ifoutvalue==nilthenreturn'<span style="display:none" data-sort-value="'..sortkey..'♠"></span>'end-- This code was copied from [[Template:Convert]] ifoutvalue==0thensortkey='5000000000000000000'elselocalmag=math.floor(math.log10(math.abs(outvalue))+1e-14)localprefixifoutvalue>0thenprefix=7000+magelseprefix=2999-magoutvalue=outvalue+10^(mag+1)endsortkey=string.format('%d',prefix)..string.format('%015.0f',math.floor(outvalue*10^(14-mag)))endreturn'<span style="display:none" data-sort-value="'..sortkey..'♠"></span>'endlocalfunctiontrim(s)returns:match('^%s*(.-)%s*$')endlocalfunctionisnotempty(s)returnsandtrim(s)~=''endfunctionchange(args)localrnd=require('Module:Math')._roundlocalprec_format=require('Module:Math')._precision_formatlocallang=mw.getContentLanguage()localfunctionformatnum(num)returnlang:parseFormattedNumber(num)andlang:formatNum(lang:parseFormattedNumber(num))ornumendlocalerrorflag=nillocaldsp=args'disp'or'row'localinv=args'invert'or'off'localsrt=args'sort'or((isnotempty(args'pre'])orisnotempty(args'sort']))and'on'or'off')localn1=(inv=='on')andtonumber(lang:parseFormattedNumber(args'2']))ortonumber(lang:parseFormattedNumber(args'1']))localn2=(inv=='on')andtonumber(lang:parseFormattedNumber(args'1']))ortonumber(lang:parseFormattedNumber(args'2']))localdec=args'dec'or'2'locals=((args'italics'or'off')=='on'and"''"or"")..((args'bold'or'off')=='on'and"'''"or"")localpc,pcr,pcrf='NA','NA'ifn1andn2andn1~=0thenpc=100*(n2/n1-1)pcr=rnd(pc,dec)ifpcr>0thenpcrf='<span style="color:green">'..s..'+'..prec_format(pc,dec)..'%'..s..'</span>'elseifpcr<0thenpcrf='<span style="color:red">'..s..prec_format(pc,dec)..'%'..s..'</span>'elsepcrf=s..prec_format(0,dec)..'%'..sendpcrf=ntsh(pcr)..pcrfelsepcrf=ntsh(nil)..s..'NA'..sifn1==nilorn2==nilthenerrorflag=1endendifdsp=='out'thenreturnpcrf,errorflagelselocalpre1=args'pre1'orargs'pre'or''localpre2=args'pre2'orargs'pre'or''localsuf1=args'suf1'orargs'suf'or''localsuf2=args'suf2'orargs'suf'or''localrspn='rowspan='..(args'rowspan'or'1')..' 'localalgn='text-align:'..(args'align'or'right')..';'localbg='background-color:'..(args'bgcolour'orargs'bgcolor'or'inherit')..';'ifrspn=='rowspan=1 'thenrspn=''endifbg=='background-color:inherit;'thenbg=''endlocalstyle=rspn..'style="'..algn..bg..'"'localsk1,sk2='',''ifsrt=='on'thensk1=ntsh(n1)sk2=ntsh(n2)endifn1~=nilthenifn1<0thenn1='−'..formatnum(-1*n1)elsen1=formatnum(n1)endelsen1=(inv=='on')and(args'2'or'')or(args'1'or'')endifn2~=nilthenifn2<0thenn2='−'..formatnum(-1*n2)elsen2=formatnum(n2)endelsen2=(inv=='on')and(args'1'or'')or(args'2'or'')endifdsp=='row2'thenreturnstyle..'|'..s..pre2..n2..suf2..s..'\n|'..style..'|'..pcrf,errorflagelseifinv=='off'thenreturnstyle..'|'..s..pre1..n1..suf1..s..'\n|'..style..'|'..s..pre2..n2..suf2..s..'\n|'..style..'|'..pcrf,errorflagelsereturnstyle..'|'..s..pre1..n2..suf1..s..'\n|'..style..'|'..s..pre2..n1..suf2..s..'\n|'..style..'|'..pcrf,errorflagendendendfunctionp.main(frame)localres,eflag=change((frame.args1orframe.args2])andframe.argsorframe:getParent().args)ifeflagthenres=res..frame:expandTemplate{title='change/error'}endreturnresendreturnp