پودمان:Math: تفاوت میان نسخه‌ها

۱٬۰۴۴ بایت اضافه‌شده ،  ‏۱۴ دسامبر ۲۰۲۱
اصلاح کاراکتر خراب
جز (۱ نسخه واردشده)
dezfulwiki>Mojtabakd
(اصلاح کاراکتر خراب)
خط ۵۰۳: خط ۵۰۳:
if precision > 0 then
if precision > 0 then
local zero_sep = lang:formatNum(1.1)
local zero_sep = lang:formatNum(1.1)
formatted_num = formatted_num .. zero_sep:sub(2,2)
formatted_num = formatted_num .. numConv("en", zero_sep):sub(2,2)


padding = precision
padding = precision
خط ۵۳۳: خط ۵۳۳:
end
end


formatted_num = numConv("fa", formatted_num)
return formatted_num
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('Module: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
end


کاربر ناشناس