Content deleted Content added
try limiting precision to 2; more than 2 is pointless |
modify convert procedure to limit the output precision for some results |
||
Line 51:
}, Value)
end,
converts = {
setConvert = function (self, invalue, factor)▼
in2cm = { factor = 2.54 },
-- Use method from [[Module:Convert]] to determine precision.▼
in2mm = { factor = 25.4 },
local outnum = invalue.number * factor▼
cm2in = { factor = 1/2.54, p2max = 1 },
mm2in = { factor = 1/25.4, p2max = 0 },
},
▲ -- Use method modified from [[Module:Convert]] to determine precision.
local convert = self.converts[units] or error('Unknown units')
▲ local outnum = invalue.number * convert.factor
local precision = invalue:getPrecision()
if outnum > 0 then
local adjust = math.log10(1/convert.factor) + math.log10(2)
local p2 = 1 - math.floor(math.log10(outnum if convert.p2max then
p2 = math.min(p2, convert.p2max)
end
precision = math.max(p1, p2)
end
self:setNumberRounded(outnum, precision)
Line 253 ⟶ 265:
end
for i = 1,13 do
local
if M_values[i].string == '' then
if I_values[i]:isValid() then
if v_class == 1 then
else
end
M_values[i]:setConvert( I_values[i],
M_values[i].variant = v_class
end
Line 267 ⟶ 279:
if M_values[i]:isValid() then
if M_values[i].variant == 1 then
else
end
I_values[i]:setConvert( M_values[i],
end
end
|