require('Module:No globals')localp={}functionp._main(n,d)localnum=tonumber(n)ifnotnumthenerror('Unable to convert "'..tostring(n)..'" to a number')endlocaldecimals=tonumber(d)ifnotdecimalsthenerror('Unable to convert "'..tostring(d)..'" to a number')endlocalmaxDecimals=14-math.floor(math.log10(num))-- to allow a maximum of 15 significant figures, which is the highest guaranteed correct with doublesifdecimals>maxDecimalsthendecimals=maxDecimalsendlocalmult=10^decimalsnum=math.floor(num*mult+0.5)/multifdecimals<0thenreturntostring(num)elsereturnstring.format('%.'..decimals..'f',num)endendfunctionp.main(frame)localargs,pargs=frame.args,frame:getParent().argsreturnp._main(mw.ext.ParserFunctions.expr(args[1]orpargs[1]),mw.ext.ParserFunctions.expr(args[2]orpargs[2]))endreturnp
มกราคม 06, 2022
มอด, decimals, เป, นมอด, ลท, กป, องก, นถาวรเน, องจากม, ความเส, ยงส, งกร, ณาอภ, ปรายการเปล, ยนแปลงใด, ทางหน, าค, ณอาจส, งคำขอแก, ไข, ไปย, งผ, แลระบบเพ, อให, แก, ไขได, หากเป, นการแก, ไขท, ไม, การค, ดค, านหร, อม, ความเห, นพ, องสน, บสน, ณย, งสามารถขอให, เล, กป, อง. niepnmxdulthithukpxngknthawrenuxngcakmikhwamesiyngsungkrunaxphipraykarepliynaeplngid thanghnakhuy khunxacsngkhakhxaekikh ipyngphuduaelrabbephuxihaekikhidhakepnkaraekikhthiimmikarkhdkhanhruxmikhwamehnphxngsnbsnun khunyngsamarthkhxihelikpxngknhnaidkhumuxkarichnganmxdul srang khunxaccatxngkarsrangkhumuxkarichngankhxngmxdulniphuekhiynsamarththakarthdlxngidthikrabathray srang khdlxk aelachudthdsxb srang khxngmxdulnioprdephimhmwdhmuipthihnayxy doc hnayxykhxngmxdulnirequire Module No globals local p function p main n d local num tonumber n if not num then error Unable to convert tostring n to a number end local decimals tonumber d if not decimals then error Unable to convert tostring d to a number end local maxDecimals 14 math floor math log10 num to allow a maximum of 15 significant figures which is the highest guaranteed correct with doubles if decimals gt maxDecimals then decimals maxDecimals end local mult 10 decimals num math floor num mult 0 5 mult if decimals lt 0 then return tostring num else return string format decimals f num end end function p main frame local args pargs frame args frame getParent args return p main mw ext ParserFunctions expr args 1 or pargs 1 mw ext ParserFunctions expr args 2 or pargs 2 end return p ekhathungcak https th wikipedia org w index php title mxdul Decimals amp oldid 5523274, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,