يمكنك أن تنشئ صفحة توثيق لهذه الوحدة (أنشئ). يمكن للمحررين تجريب تعديلاتهم على الوحدة في صفحات ملعب (أنشئ | مرآة) ومختبر (أنشئ). من فضلك أضف التصنيفات في الصفحة الفرعية للقالب /شرح. الصفحات الفرعية لـ وحدة.
--[[This module provides a number of basic mathematical operations.]]localyesno,getArgs-- lazily initializedlocalp={}-- Holds functions to be returned from #invoke, and functions to make available to other Lua modules.localwrap={}-- Holds wrapper functions that process arguments from #invoke. These act as intemediary between functions meant for #invoke and functions meant for Lua.functionp._round(value,precision)localrescale=math.pow(10,precisionor0);returnmath.floor(value*rescale+0.5)/rescale;endfunctionp.newFromWikidataValue(frame)upeer=frame.upperBoundifnotupeerthenupeer='0'endlower=frame.lowerBoundifnotlowerthenlower='0'endlocaldiff=math.abs(tonumber(upeer)-tonumber(frame.amount))localdiff2=math.abs(tonumber(lower)-tonumber(frame.amount))ifdiff2>diffthendiff=diff2end-- TODO, att fixa så att inte 1234.000 'huggs av' till 1234locallang=mw.language.new('ar')ifdiff==0thenreturnlang:formatNum(tonumber(frame.amount))elselocallog=-math.log10(diff)returnlang:formatNum(p._round(frame.amount,math.ceil(log)))endendlocalmt={__index=function(t,k)returnfunction(frame)ifnotgetArgsthengetArgs=require('Module:Arguments').getArgsendreturnwrap[k](getArgs(frame))-- Argument processing is left to Module:Arguments. Whitespace is trimmed and blank arguments are removed.endend}returnsetmetatable(p,mt)