Module:WeightToPercent: Difference between revisions
Jump to navigation
Jump to search
imported>Septembre bonjour je sais pas faire un produit en croix........ bon normalement ça devrait marcher |
imported>Septembre tentative d'arrondi 1 décimale |
||
| Line 9: | Line 9: | ||
elseif weight == 0 then return 0 | elseif weight == 0 then return 0 | ||
end | end | ||
return weight * 100 / totalweight | return tonumber(string.format("%.1f", weight * 100 / totalweight)) | ||
end | end | ||
return p | return p | ||
Revision as of 16:13, 19 November 2025
Documentation for this module may be created at Module:WeightToPercent/doc
local p = {}
function p.convert(frame)
local weight = frame.args['weight']
local totalweight = frame.args['total']
if weight == nil then return "ERROR: weight input (1rst arg) is nil"
elseif totalweight == nil then return "ERROR: totalweight (2nd arg) input is nil"
elseif weight == 0 then return 0
end
return tonumber(string.format("%.1f", weight * 100 / totalweight))
end
return p