号什么意思| 彷徨是什么意思| 上焦湿热吃什么中成药| 胃不舒服吃什么药好| 百无一用是什么意思| 睡觉腿抽筋是什么原因| 柯基为什么要断尾巴| 肠道紊乱有什么症状| 什么空调省电| 面膜什么牌子好| 国保大队是干什么的| 什么是佛跳墙| 经常耳鸣是为什么| 白居易是诗什么| 为什么会流鼻血| 缺硒有什么症状| 一个月一个并念什么| 逐年是什么意思| 单侧流鼻血是什么原因| 尖锐湿疣是什么样的| 1964年是什么年| 睡眠障碍挂什么科| 梦见妖魔鬼怪是什么意思| 肚脐右边疼是什么原因| 姐姐的女儿叫什么称呼| 第一次见面送女生什么花| 疖肿是什么意思| 割包皮有什么影响| 五险一金指什么| 痹病是什么意思| 报价是什么意思| 嘴突然歪是什么原因造成的| 锁骨属于什么骨| bid是什么意思啊| 告加鸟念什么| 狮子是什么科| 壮腰健肾丸有什么功效| 为什么运动完会恶心头晕想吐| 提辖相当于现在什么官| 车顶放饮料是什么意思| 沼泽地是什么意思| 荔枝可以做什么| 犯罪是什么意思| 压缩性骨折是什么意思| 儿童铅超标有什么症状| 什么是区块链技术| 什么是火象星座| 离婚需要什么资料| 慢性胆囊炎吃什么药| 苹果醋什么时候喝最好| 后背长痘痘用什么药膏| 女人什么时候停经| 怀孕前三个月吃什么好| 关节积液是什么原因造成的| 才高八斗代表什么生肖| 铁马是什么| 激素六项检查挂什么科| 一米阳光是什么意思| 为什么二楼比三楼好| 侧记是什么意思| 按摩脸部有什么好处| 甲壳素是什么东西| 钙片什么时候吃最好| 黄瓜为什么会苦| 公积金基数是什么意思| 痛风可以吃什么鱼| 梦见蛇和老鼠是什么意思| 斐乐属于什么档次| 消停是什么意思| 绝眼是什么原因引起的| 阳痿早泄用什么药| 打生长激素有什么副作用| 备孕不能吃什么| 腿麻木是什么原因引起的| 观落阴是什么意思| 看日出是什么生肖| 心脏房颤吃什么药最好| 7月8号是什么日子| sco是什么意思| ipl是什么意思| 鸟大了什么林子都有| 办身份证要穿什么衣服| 头七是什么意思| 22度穿什么衣服合适| 肩膀疼挂什么科室最好| 小孩子睡觉流口水是什么原因| 什么叫子宫腺肌症| ems什么意思| 脾胃阴虚吃什么中成药| as医学上是什么意思| 什么是腹泻| 面肌痉挛挂什么科| 今天是什么纪念日| 东四命是什么意思| 太平天国失败的根本原因是什么| 活学活用是什么意思| 晚上多梦是什么原因| 讳疾忌医是什么意思| 玉米什么时候成熟| barbie是什么意思| 淋巴结发炎挂什么科| 刺猬爱吃什么| 小蛮腰什么意思| 圭是什么意思| 孕妇吃蓝莓对胎儿有什么好处| 小儿电解质补给液有什么作用| 水里有什么| 霍山石斛有什么作用| 口臭药店买什么药吃| 柯基为什么要断尾巴| 签注是什么| 鬼迷日眼是什么意思| 尿隐血十1是什么意思| 子宫切除有什么影响| 道理是什么意思| 基础代谢率是什么意思| 严重贫血的人吃什么补血最快| 举足轻重什么意思| 中性粒细胞低是什么原因| 熹字五行属什么| 玉屏风治什么病最好| 一直放屁什么原因| 中央电视台台长什么级别| 全糖是什么意思| 什么叫御姐| 知了什么时候叫| 市公安局局长是什么级别| 梦见青蛙是什么意思| 投其所好是什么意思| 缺钾吃什么| 边缘性人格障碍是什么| 699是什么意思| 巫师是什么意思| 肉炒什么好吃| 例假淋漓不尽是什么原因造成的| 72年属什么| 社保断了有什么影响| 蛋白尿是什么原因引起的| 什么是脂蛋白a| 二月初十是什么星座| 莫代尔是什么面料| 一带一路是指什么| 嘴巴干是什么原因| 婴儿有眼屎是什么原因引起的| 什么盐好| 除了肠镜还有什么方法检查肠道| 月经来了吃什么好| 中二病的意思是什么| 72年属鼠是什么命| 心脏不好吃什么| 牡丹花有什么颜色| hpv有什么症状| 永字五行属什么| 尿里红细胞高什么原因| 县委书记属于什么级别| 金刚石是由什么构成的| 乙肝表面抗原250是什么意思| 尿路感染吃什么药消炎| 郑州有什么好玩的| 三月十六是什么星座| 欺骗餐是什么意思| 吃红萝卜有什么好处| 尿隐血什么意思| 绿豆汤为什么是红色的| 乘的部首是什么| 紫苏有什么功效与作用| 吐气如兰是什么意思| 27岁属相是什么生肖| 手术后吃什么恢复快| 肉炒什么菜谱大全| 甲状腺1类是什么意思| 什么民族不吃猪肉| 骨折吃什么水果| 查结核做什么检查| 19年是什么年| 莲子不能和什么一起吃| 活动性肺结核是什么意思| 十二年义务教育什么时候实行| 什么首什么胸| 维生素b是什么| 神经官能症是什么| 不着相是什么意思| 东厂是什么意思| 乙肝表面抗原大于250是什么意思| 大小眼是什么原因| 什么叫pc| 九门提督相当于现在什么官| 人大副主任是什么级别| 骨加后念什么| 尿维生素c弱阳性是什么意思| ipad什么时候出新款| 四叶草是什么意思| 脾虚是什么原因引起的| 肠梗阻是什么意思| hpv52型阳性是什么意思严重吗| 苟同什么意思| 小腿内侧是什么经络| 8023是什么意思啊| 丹毒是什么原因引起的| 喜欢穿黑色衣服的女人是什么性格| 百草霜是什么| 黄色裤子搭配什么颜色上衣| 母亲节送婆婆什么礼物| 预防医学是干什么的| 脚踝浮肿是什么原因| 繁星是什么意思| 患者是什么意思| 什么的海藻| 3月19是什么星座| 内径是什么意思| 猫上门为什么不能赶走| 陈皮泡水喝有什么好处| 零和博弈是什么意思| 狼毫毛笔是什么毛| 什么饮料能解酒| 萤火虫为什么会发光简单回答| 什么是高钾血症| 冠字五行属什么| 胃肠湿热吃什么中成药| 变形虫是什么生物| 什么是心脏病| 为什么合欢树又叫鬼树| 40岁属什么生肖| 马眼是什么意思| 太阳穴疼是什么原因| 突然头晕冒虚汗什么原因| 梦见生了个孩子是什么意思| 绝倒是什么意思| 狐臭是什么味道| 大学生村官是什么编制| gigi 是什么意思| 备孕为什么要吃叶酸| 准备的近义词是什么| 海带和什么不能一起吃| 什么是| ray是什么意思| 吃什么降血压效果最好| 睾丸疼挂什么科| 人老是放屁是什么原因| 舌裂吃什么药| 吃什么对心脏好改善供血不足| 空调健康模式是什么意思| 理数是什么意思| 尿结晶是什么意思| 菠萝蜜和什么不能一起吃| 撑台脚是什么意思| 蓝莓有什么功效与作用| au是什么意思| 鸭胗是什么器官| 脸上起红疙瘩是什么原因| 王源粉丝叫什么| 二月一日是什么星座| 河水像什么| 血清载脂蛋白b偏高是什么意思| 深井冰什么意思| 肾盂肾炎吃什么药好| 脚掌脱皮是什么原因| 嫪毐是什么意思| 太平洋中间是什么| 灶心土是什么| 88什么意思| 冷萃是什么意思| 兵不血刃的意思是什么| 血清铁低是什么原因| 百度Pojdi na vsebino

俄媒评中国航天:卫星数量超俄一技术还领先美国

Iz Wikipedije, proste enciklopedije
Documentation icon Dokumentacija modula[predogled] [uredi] [zgodovina] [osve?i]
百度 RNG在即将到来的季后赛,如果还是在练阵容的话,对于整个团战来说都有些不公平,于是上单到底谁是这个赛季的主力引起了许多网友的争议。

This module provides a number of mathematical functions. These functions can be used from #invoke or from other Lua modules.

Use from other Lua modules

[uredi kodo]

To use the module from normal wiki pages, no special preparation is needed. If you are using the module from another Lua module, first you need to load it, like this:

local mm = require('Module:Math')

(The mm variable stands for Module Math; you can choose something more descriptive if you prefer.)

Most functions in the module have a version for Lua and a version for #invoke. It is possible to use the #invoke functions from other Lua modules, but using the Lua functions has the advantage that you do not need to access a Lua frame object. Lua functions are preceded by _, whereas #invoke functions are not.

random

[uredi kodo]
{{#invoke:math|random}}
{{#invoke:math|random|max_value}}
{{#invoke:math|random|min_value|max_value}}
mm._random()
mm._random(max_value)
mm._random(min_value, max_value)

Generates a random number.

  • If no arguments are specified, the number produced is greater than or equal to 0 and less than 1.
  • If one argument is provided, the number produced is an integer between 1 and that argument. The argument must be a positive integer.
  • If two arguments are provided, the number produced is an integer between the first and second arguments. Both arguments must be integers, but can be negative.

This function will not work properly for numbers less than ?232 and greater than 232 ? 1. If you need to use numbers outside of this range, it is recommended that you use Module:Random.

order

[uredi kodo]
{{#invoke:math|order|n}}
mm._order(n)

Determines the order of magnitude of a number.

precision

[uredi kodo]
{{#invoke:math|precision|n}}
{{#invoke:math|precision|x=n}}
mm._precision(number_string)

Detemines the precision of a number. For example, for "4" it will return "0", for "4.567" it will return "3", and for "100" it will return "-2".

The function attempts to parse the string representation of the number, and detects whether the number uses E notation. For this reason, when called from Lua, very large numbers or very precise numbers should be directly input as strings to get accurate results. If they are input as numbers, the Lua interpreter will change them to E notation and this function will return the precision of the E notation rather than that of the original number. This is not a problem when the number is called from #invoke, as all input from #invoke is in string format.

{{#invoke:math|max|v1|v2|v3|...}}
mm._max(v1, v2, v3, ...)

Returns the maximum value from the values specified. Values that cannot be converted to numbers are ignored.

median

[uredi kodo]
{{#invoke:math|median|v1|v2|v3|...}}
mm._median(v1, v2, v3, ...)

Returns the median value from the values specified. Values that cannot be converted to numbers are ignored.

{{#invoke:math|min|v1|v2|v3|...}}
mm._min(v1, v2, v3, ...)

Returns the minimum value from the values specified. Values that cannot be converted to numbers are ignored.

{{#invoke:math|sum|v1|v2|v3|...}}
mm._sum(v1, v2, v3, ...)

Returns the sum of the values specified. Values that cannot be converted to numbers are ignored.

average

[uredi kodo]
{{#invoke:math|average|v1|v2|v3|...}}
mm._average(v1, v2, v3, ...)

Returns the average of the values specified. (More precisely, the value returned is the arithmetic mean.) Values that cannot be converted to numbers are ignored.

round

[uredi kodo]
{{#invoke:math|round|value|precision}}
{{#invoke:math|round|value=value|precision=precision}}
mm._round(value, precision)

Rounds a number to the specified precision.

Note: As of October 2019, there is a bug in the display of some rounded numbers. When trying to round a number that rounds to "n.0", like "1.02", to the nearest tenth of a digit (i.e. |r=1), this function should display "1.0", but it unexpectedly displays "1". Use the |precision_format= parameter instead.

log10

[uredi kodo]
{{#invoke:math | log10 | x}}
mm._log10(x)

Returns log10(x), the logarithm of x using base 10.

{{#invoke:math|mod|x|y}}
mm._mod(x, y)

Gets x modulo y, or the remainder after x has been divided by y. This is accurate for integers up to 253; for larger integers Lua's modulo operator may return an erroneous value. This function deals with this problem by returning 0 if the modulo given by Lua's modulo operator is less than 0 or greater than y.

{{#invoke:math|gcd|v1|v2|...}}
mm._gcd(v1, v2, ...)

Finds the greatest common divisor of the values specified. Values that cannot be converted to numbers are ignored.

precision_format

[uredi kodo]
{{#invoke:math|precision_format|value_string|precision}}
mm._precision_format(value_string, precision)

Rounds a number to the specified precision and formats according to rules originally used for {{Rnd}}. Output is a string.

Parameter precision should be an integer number of digits after the decimal point. Negative values are permitted. Non-integers give unexpected results. Positive values greater than the input precision add zero-padding, negative values greater than the input order can consume all digits.

Formatting 8,765.567 with {{#invoke:Math|precision_format|8765.567|precision}} gives:

precision Result
2 8.765,57
-2 8.800
6 8.765,567000
-6 0
2.5 8.765,5680426633
-2.5 8.854,3774484715

divide

[uredi kodo]
{{#invoke:Math|divide|x|y|round=|precision=}}
mm._divide(x, y, round, precision)

Divide x by y.

  • If y if not a number, it is returned.
  • Otherwise, if x is not a number, it is returned.
  • If round is true ("yes" for #invoke), the result has no decimals
  • Precision indicates how many digits of precision the result should have

If any of the arguments contain HTML tags, they are returned unchanged, allowing any errors in calculating the arguments to the division function to be propagated to the calling template.

cleanNumber

[uredi kodo]
local number, number_string = mm._cleanNumber(number_string)

A helper function that can be called from other Lua modules, but not from #invoke. This takes a string or a number value as input, and if the value can be converted to a number, cleanNumber returns the number and the number string. If the value cannot be converted to a number, cleanNumber returns nil, nil.

See also

[uredi kodo]
--[[

This module provides a number of basic mathematical operations.

]]

local yesno, getArgs -- lazily initialized

local p = {} -- Holds functions to be returned from #invoke, and functions to make available to other Lua modules.
local wrap = {} -- Holds wrapper functions that process arguments from #invoke. These act as intemediary between functions meant for #invoke and functions meant for Lua.

--[[
Helper functions used to avoid redundant code.
]]

local function err(msg)
	-- Generates wikitext error messages.
	return mw.ustring.format('<strong class="error">Formatting error: %s</strong>', msg)
end

local function unpackNumberArgs(args)
	-- Returns an unpacked list of arguments specified with numerical keys.
	local ret = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			table.insert(ret, v)
		end
	end
	return unpack(ret)
end

local function makeArgArray(...)
	-- Makes an array of arguments from a list of arguments that might include nils.
	local args = {...} -- Table of arguments. It might contain nils or non-number values, so we can't use ipairs.
	local nums = {} -- Stores the numbers of valid numerical arguments.
	local ret = {}
	for k, v in pairs(args) do
		v = p._cleanNumber(v)
		if v then
			nums[#nums + 1] = k
			args[k] = v
		end
	end
	table.sort(nums)
	for i, num in ipairs(nums) do
		ret[#ret + 1] = args[num]
	end
	return ret
end

local function fold(func, ...)
	-- Use a function on all supplied arguments, and return the result. The function must accept two numbers as parameters,
	-- and must return a number as an output. This number is then supplied as input to the next function call.
	local vals = makeArgArray(...)
	local count = #vals -- The number of valid arguments
	if count == 0 then return
		-- Exit if we have no valid args, otherwise removing the first arg would cause an error.
		nil, 0
	end
	local ret = table.remove(vals, 1)
	for _, val in ipairs(vals) do
		ret = func(ret, val)
	end
	return ret, count
end

--[[
Fold arguments by selectively choosing values (func should return when to choose the current "dominant" value).
]]
local function binary_fold(func, ...)
	local value = fold((function(a, b) if func(a, b) then return a else return b end end), ...)
	return value
end

--[[
random

Generate a random number

Usage:
{{#invoke: Math | random }}
{{#invoke: Math | random | maximum value }}
{{#invoke: Math | random | minimum value | maximum value }}
]]

function wrap.random(args)
	local first = p._cleanNumber(args[1])
	local second = p._cleanNumber(args[2])
	return p._random(first, second)
end

function p._random(first, second)
	math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000))
	-- math.random will throw an error if given an explicit nil parameter, so we need to use if statements to check the params.
	if first and second then
		if first <= second then -- math.random doesn't allow the first number to be greater than the second.
			return math.random(first, second)
		end
	elseif first then
		return math.random(first)
	else
		return math.random()
	end
end

--[[
order

Determine order of magnitude of a number

Usage:
{{#invoke: Math | order | value }}
]]

function wrap.order(args)
	local input_string = (args[1] or args.x or '0');
	local input_number = p._cleanNumber(input_string);
	if input_number == nil then
		return err('order of magnitude input appears non-numeric')
	else
		return p._order(input_number)
	end
end

function p._order(x)
	if x == 0 then return 0 end
	return math.floor(math.log10(math.abs(x)))
end

--[[
precision

Detemines the precision of a number using the string representation

Usage:
{{ #invoke: Math | precision | value }}
]]

function wrap.precision(args)
	local input_string = (args[1] or args.x or '0');
	local trap_fraction = args.check_fraction;
	local input_number;

	if not yesno then
		yesno = require('Modul:Yesno')
	end
	if yesno(trap_fraction, true) then -- Returns true for all input except nil, false, "no", "n", "0" and a few others. See [[Modul:Yesno]].
		local pos = string.find(input_string, '/', 1, true);
		if pos ~= nil then
			if string.find(input_string, '/', pos + 1, true) == nil then
				local denominator = string.sub(input_string, pos+1, -1);
				local denom_value = tonumber(denominator);
				if denom_value ~= nil then
					return math.log10(denom_value);
				end
			end
		end
	end

	input_number, input_string = p._cleanNumber(input_string);
	if input_string == nil then
		return err('precision input appears non-numeric')
	else
		return p._precision(input_string)
	end
end

function p._precision(x)
	if type(x) == 'number' then
		x = tostring(x)
	end
	x = string.upper(x)

	local decimal = x:find('%.')
	local exponent_pos = x:find('E')
	local result = 0;

	if exponent_pos ~= nil then
		local exponent = string.sub(x, exponent_pos + 1)
		x = string.sub(x, 1, exponent_pos - 1)
		result = result - tonumber(exponent)
	end

	if decimal ~= nil then
		result = result + string.len(x) - decimal
		return result
	end

	local pos = string.len(x);
	while x:byte(pos) == string.byte('0') do
		pos = pos - 1
		result = result - 1
		if pos <= 0 then
			return 0
		end
	end

	return result
end


--[[
max

Finds the maximum argument

Usage:
{{#invoke:Math| max | value1 | value2 | ... }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.max(args)
	return p._max(unpackNumberArgs(args))
end

function p._max(...)
	local max_value = binary_fold((function(a, b) return a > b end), ...)
	if max_value then
		return max_value
	end
end

--[[
median

Find the median of set of numbers

Usage:
{{#invoke:Math | median | number1 | number2 | ...}}
OR
{{#invoke:Math | median }}
]]

function wrap.median(args)
	return p._median(unpackNumberArgs(args))
end

function p._median(...)
	local vals = makeArgArray(...)
	local count = #vals
	table.sort(vals)

	if count == 0 then
		return 0
	end

	if p._mod(count, 2) == 0 then
		return (vals[count/2] + vals[count/2+1])/2
	else
		return vals[math.ceil(count/2)]
	end
end

--[[
min

Finds the minimum argument

Usage:
{{#invoke:Math| min | value1 | value2 | ... }}
OR
{{#invoke:Math| min }}

When used with no arguments, it takes its input from the parent
frame.  Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.min(args)
	return p._min(unpackNumberArgs(args))
end

function p._min(...)
	local min_value = binary_fold((function(a, b) return a < b end), ...)
	if min_value then
		return min_value
	end
end

--[[
sum

Finds the sum

Usage:
{{#invoke:Math| sum | value1 | value2 | ... }}
OR
{{#invoke:Math| sum }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.sum(args)
	return p._sum(unpackNumberArgs(args))
end

function p._sum(...)
	local sums, count = fold((function(a, b) return a + b end), ...)
	if not sums then
		return 0
	else
		return sums
	end
end

--[[
average

Finds the average

Usage:
{{#invoke:Math| average | value1 | value2 | ... }}
OR
{{#invoke:Math| average }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.average(args)
	return p._average(unpackNumberArgs(args))
end

function p._average(...)
	local sum, count = fold((function(a, b) return a + b end), ...)
	if not sum then
		return 0
	else
		return sum / count
	end
end

--[[
round

Rounds a number to specified precision

Usage:
{{#invoke:Math | round | value | precision }}

--]]

function wrap.round(args)
	local value = p._cleanNumber(args[1] or args.value or 0)
	local precision = p._cleanNumber(args[2] or args.precision or 0)
	if value == nil or precision == nil then
		return err('round input appears non-numeric')
	else
		return p._round(value, precision)
	end
end

function p._round(value, precision)
	local rescale = math.pow(10, precision or 0);
	return math.floor(value * rescale + 0.5) / rescale;
end

--[[
log10

returns the log (base 10) of a number

Usage:
{{#invoke:Math | log10 | x }}
]]

function wrap.log10(args)
	return math.log10(args[1])
end

--[[
mod

Implements the modulo operator

Usage:
{{#invoke:Math | mod | x | y }}

--]]

function wrap.mod(args)
	local x = p._cleanNumber(args[1])
	local y = p._cleanNumber(args[2])
	if not x then
		return err('first argument to mod appears non-numeric')
	elseif not y then
		return err('second argument to mod appears non-numeric')
	else
		return p._mod(x, y)
	end
end

function p._mod(x, y)
	local ret = x % y
	if not (0 <= ret and ret < y) then
		ret = 0
	end
	return ret
end

--[[
gcd

Calculates the greatest common divisor of multiple numbers

Usage:
{{#invoke:Math | gcd | value 1 | value 2 | value 3 | ... }}
--]]

function wrap.gcd(args)
	return p._gcd(unpackNumberArgs(args))
end

function p._gcd(...)
	local function findGcd(a, b)
		local r = b
		local oldr = a
		while r ~= 0 do
			local quotient = math.floor(oldr / r)
			oldr, r = r, oldr - quotient * r
		end
		if oldr < 0 then
			oldr = oldr * -1
		end
		return oldr
	end
	local result, count = fold(findGcd, ...)
	return result
end

--[[
precision_format

Rounds a number to the specified precision and formats according to rules
originally used for {{template:Rnd}}.  Output is a string.

Usage:
{{#invoke: Math | precision_format | number | precision }}
]]

function wrap.precision_format(args)
	local value_string = args[1] or 0
	local precision = args[2] or 0
	return p._precision_format(value_string, precision)
end

function p._precision_format(value_string, precision)
	-- For access to Mediawiki built-in formatter.
	local lang = mw.getContentLanguage();

	local value
	value, value_string = p._cleanNumber(value_string)
	precision = p._cleanNumber(precision)

	-- Check for non-numeric input
	if value == nil or precision == nil then
		return err('invalid input when rounding')
	end

	local current_precision = p._precision(value)
	local order = p._order(value)

	-- Due to round-off effects it is neccesary to limit the returned precision under
	-- some circumstances because the terminal digits will be inaccurately reported.
	if order + precision >= 14 then
		if order + p._precision(value_string) >= 14 then
			precision = 13 - order;
		end
	end

	-- If rounding off, truncate extra digits
	if precision < current_precision then
		value = p._round(value, precision)
		current_precision = p._precision(value)
	end

	local formatted_num = lang:formatNum(math.abs(value))
	local sign

	-- Use proper unary minus sign rather than ASCII default
	if value < 0 then
		sign = '?'
	else
		sign = ''
	end

	-- Handle cases requiring scientific notation
	if string.find(formatted_num, 'E', 1, true) ~= nil or math.abs(order) >= 9 then
		value = value * math.pow(10, -order)
		current_precision = current_precision + order
		precision = precision + order
		formatted_num = lang:formatNum(math.abs(value))
	else
		order = 0;
	end
	formatted_num = sign .. formatted_num

	-- Pad with zeros, if needed
	if current_precision < precision then
		local padding
		if current_precision <= 0 then
			if precision > 0 then
				local zero_sep = lang:formatNum(1.1)
				formatted_num = formatted_num .. zero_sep:sub(2,2)

				padding = precision
				if padding > 20 then
					padding = 20
				end

				formatted_num = formatted_num .. string.rep('0', padding)
			end
		else
			padding = precision - current_precision
			if padding > 20 then
				padding = 20
			end
			formatted_num = formatted_num .. string.rep('0', padding)
		end
	end

	-- Add exponential notation, if necessary.
	if order ~= 0 then
		-- Use proper unary minus sign rather than ASCII default
		if order < 0 then
			order = '?' .. lang:formatNum(math.abs(order))
		else
			order = lang:formatNum(order)
		end

		formatted_num = formatted_num .. '<span style="margin:0 .15em 0 .25em">×</span>10<sup>' .. order .. '</sup>'
	end

	return formatted_num
end

--[[
divide

Implements the division operator

Usage:
{{#invoke:Math | divide | x | y | round= | precision= }}

--]]
function wrap.divide(args)
	local x = args[1]
	local y = args[2]
	local round = args.round
	local precision =  args.precision
	if not yesno then
		yesno = require('Modul:Yesno')
	end
	return p._divide(x, y, yesno(round), precision)
end

function p._divide(x, y, round, precision)
	if y == nil or y == "" then
		return err("Empty divisor")
	elseif not tonumber(y) then
		if type(y) == 'string' and string.sub(y, 1, 1) == '<' then
			return y
		else
			return err("Not a number: " .. y)
		end
	elseif x == nil or x == "" then
		return err("Empty dividend")
	elseif not tonumber(x) then
		if type(x) == 'string' and string.sub(x, 1, 1) == '<' then
			return x
		else
			return err("Not a number: " .. x)
		end
	else
		local z = x / y
		if round then
			return p._round(z, 0)
		elseif precision then
			return p._round(z, precision)
		else
			return z	
		end
	end
end

--[[
Helper function that interprets the input numerically.  If the
input does not appear to be a number, attempts evaluating it as
a parser functions expression.
]]

function p._cleanNumber(number_string)
	if type(number_string) == 'number' then
		-- We were passed a number, so we don't need to do any processing.
		return number_string, tostring(number_string)
	elseif type(number_string) ~= 'string' or not number_string:find('%S') then
		-- We were passed a non-string or a blank string, so exit.
		return nil, nil;
	end

	-- Attempt basic conversion
	local number = tonumber(number_string)

	-- If failed, attempt to evaluate input as an expression
	if number == nil then
		local success, result = pcall(mw.ext.ParserFunctions.expr, number_string)
		if success then
			number = tonumber(result)
			number_string = tostring(number)
		else
			number = nil
			number_string = nil
		end
	else
		number_string = number_string:match("^%s*(.-)%s*$") -- String is valid but may contain padding, clean it.
		number_string = number_string:match("^%+(.*)$") or number_string -- Trim any leading + signs.
		if number_string:find('^%-?0[xX]') then
			-- Number is using 0xnnn notation to indicate base 16; use the number that Lua detected instead.
			number_string = tostring(number)
		end
	end

	return number, number_string
end

--[[
Wrapper function that does basic argument processing. This ensures that all functions from #invoke can use either the current
frame or the parent frame, and it also trims whitespace for all arguments and removes blank arguments.
]]

local mt = { __index = function(t, k)
	return function(frame)
		if not getArgs then
			getArgs = require('Modul:Arguments').getArgs
		end
		return wrap[k](getArgs(frame))  -- Argument processing is left to Modul:Arguments. Whitespace is trimmed and blank arguments are removed.
	end
end }

return setmetatable(p, mt)
傲娇什么意思 全身而退是什么意思 喝酒头晕是什么原因 晚上8点半是什么时辰 恶露后期为什么是臭的
什么游戏最赚钱 水果皇后是什么水果 梦见家里发大水了是什么征兆 争辩的近义词是什么 女人脚发热是什么原因
榴莲树长什么样子 一个土一个斤念什么 陕西有什么特产 高血压需要注意些什么 小浣熊吃什么
头皮软绵绵的什么原因 孩子营养不良吃什么 透明质酸是什么 曹操的父亲叫什么名字 过敏是什么样子的
om什么意思hcv7jop4ns5r.cn 按摩有什么好处和坏处gysmod.com 为什么不能天天做有氧运动hcv7jop5ns1r.cn 宝五行属性是什么hcv8jop3ns6r.cn 大肠在人体什么位置图hcv8jop1ns7r.cn
09年属什么生肖hcv9jop3ns3r.cn 非食健字是什么意思hcv8jop9ns9r.cn 螃蟹跟什么不能一起吃hcv8jop8ns0r.cn 怀孕建卡需要什么材料hcv8jop6ns9r.cn 刀厄痣是什么意思hcv9jop0ns3r.cn
日单是什么意思hcv7jop6ns0r.cn maga是什么意思hcv9jop5ns0r.cn 麸子是什么东西hcv8jop4ns9r.cn 三头六臂指什么生肖hcv8jop9ns0r.cn 什么是基础代谢hcv9jop5ns5r.cn
不来月经是什么原因hcv8jop4ns1r.cn 是什么样的hcv7jop4ns7r.cn 帕斯是什么意思hcv7jop9ns4r.cn 超声科检查什么hcv8jop6ns9r.cn 足齐念什么hcv7jop6ns5r.cn
百度