Content deleted Content added
fix my mistake with 'checkFlag(...) or checkFlag(...)' (false or true is true); fix similar potential problem with checkFlag usage; finish removing unused variable |
try using the method from Module:Convert to determine precision; this is better in some ways and worse in others |
||
Line 50:
string = str,
}, Value)
end,
setConvert = function (self, invalue, factor)
-- Use method from [[Module:Convert]] to determine precision.
local outnum = invalue.number * factor
if outnum > 0 then
local adjust = math.log10(1/factor) + math.log10(2)
precision = math.max(math.floor(precision + adjust), 1 - math.floor(math.log10(outnum)))
end
self:setNumberRounded(outnum, precision)
end,
setNumberRounded = function (self, number, precision)
precision = 3
end
self.number = math_mod._round(number, precision)
if precision < 0 then
local fmt = '%.' .. string.format('%d', precision) .. 'f'▼
self.string =
else
▲ local fmt = '%.' .. string.format('%d', precision) .. 'f'
self.string = string.format(fmt, self.number)
end
end,
}
Line 237 ⟶ 253:
end
for i = 1,13 do
local
if M_values[i].string == '' then
if I_values[i]:isValid() then
if v_class == 1 then
factor = 2.54
M_values[i]:setNumberRounded( I_values[i].number*2.54, p )▼
else
factor = 25.4
end
M_values[i].variant = v_class
end
Line 252 ⟶ 267:
if M_values[i]:isValid() then
if M_values[i].variant == 1 then
factor = 1/2.54
▲ p = M_values[i]:getPrecision()
else
factor = 1/25.4
end
I_values[i]:
end
end
|