Module:Convert: Difference between revisions

builtin hand units default to show name not symbol since "h" is "hour" and is uncommon for "hand"
(Theodore O'Connor was a {{hands|14.1+3/4}} pony means 14 hands + 1.75 inches = 57.75 inches (although module rounds that to 57.8 by default))
(builtin hand units default to show name not symbol since "h" is "hour" and is uncommon for "hand")
Line 694:
-- [[mile]]s per [[United States customary units|U.S.]] [[quart]]
-- [[long ton]]s per [[short ton]]
-- Assume that links cannot be nested (never like "[[abc[[def]]ghi]]").
-- This uses a simple and efficient procedure that works for most cases.
-- Some units (if used) would require more, and can later think about
Line 1,833:
-- Input info.clean uses en digits (it has been translated, if necessary).
-- Output show uses en or non-en digits as appropriate, or can be spelled.
local invalue, inclean, show, exponent, singular
if info then
invalue, inclean = info.value, info.clean
Line 1,848:
-- precision if the output uses scientific notation (very large, or very
-- small). Not worth more complexity as these cases should be very rare.
if parms.abbr_org == nil then
out_current.usename = true -- default is to show name not symbol
}end
local dummy_unit_table = { scale = out_current.scale }
local success, outinfo = cvtround(parms, info, in_current, dummy_unit_table)
Line 1,877 ⟶ 1,880:
inches = inches:sub(1, 1) .. inches:sub(3)
end
outinfo.show = outinfo.sign .. with_separator(parms, format('%d', hands)) .. numdot .. from_en(inches)
return true, {
return sign =true, outinfo.sign,
singular = outinfo.singular,
show = outinfo.sign .. with_separator(parms, format('%d', hands)) .. numdot .. from_en(inches)
}
end
local outvalue, extra = convert(invalue, inclean, in_current, out_current)
Line 1,898:
outvalue = -outvalue
end
local success, use_default_precision, show, exponent
local precision = parms.precision
if not precision then
Line 1,935:
end
end
end
if (show == '1' or show:match('^1%.0*$') ~= nil) and not isnegative then
-- Use match because on some systems 0.99999999999999999 is 1.0.
singular = true
end
local t = format_number(parms, show, exponent, isnegative)
-- Set singular -- Useusing match because on some systems 0.99999999999999999 is 1.0.
t.singular = singular
ift.singular = ((show == '1' or show:match('^1%.0*$') ~= nil) and not isnegative then)
t.raw_absvalue = outvalue -- absolute value before rounding
t.use_default_precision = use_default_precision
Anonymous user