Jump to content

User:Johnuniq/Convert notes

From Wikipedia, the free encyclopedia

While working on Module:Convert, I have noticed some issues with the Template:Convert family. That is hardly surprising given the enormous number of units and options that it efficiently handles, but I thought it would be useful to document what I found. I put a link to this at Template talk:Convert (now archived here) on 13 February 2013, but I'm putting this here because it's too long for that talk page. If anyone feels inclined to work on this page, please edit as wanted. Johnuniq (talk) 23:46, 25 March 2013 (UTC)

  • Some resolved items have been removed, and some more sections have been added. Johnuniq (talk) 02:49, 16 September 2013 (UTC)
  • Most of the issues or precision problems were corrected in the markup-based Convert during late November 2013. -Wikid77 (talk) 06:43, 30 November 2013 (UTC)

Issues

[edit]

The following should convert to kelvin:

  • {{convert|123|F|K|abbr=in}} → 123 °F (324 kelvins)
  • {{convert|123|F|K|abbr=off}} → 123 degrees Fahrenheit (324 kelvins)
  • {{convert|123|C|K|abbr=in}} → 123 °C (396 kelvins)
  • {{convert|123|C|K|abbr=off}}                → 123 degrees Celsius (396 kelvins)
  • {{convert/sandboxlua|123|C|K|abbr=off}} → 123 degrees Celsius (396 kelvins)
Fixed for kelvins. -Wikid77 21:35, 27 November 2013 (UTC)

Some minor issues may need adjusting:

  • {{convert|-12|lb|kg|disp=5}} → −12 pounds (−5 kg)* ["-5" uses a hyphen rather than a minus sign]

Unit Mach accepts parameter 4 as an altitude. However, that gives incorrect results and outputs a hidden category (Category:Pages with bad rounding precision) if the altitude does not contain a comma ("95,000" is ok, but "95000" is incorrect). For example:

  • {{convert|10|Mach|95,000}} → Mach 10 (10,800 km/h; 6,730 mph) ["6,730 mph; 10,840 km/h" is correct]
  • {{convert|10|Mach|95000}} → Mach 10 (10,800 km/h; 6,730 mph) [as in Boeing Small Launch Vehicle]

{{convert/Mach}} has incorrect values in the table of altitudes (the switch values are repeated, starting at "21 <!-- 105 -->". For example (the output should be "(16,000 mph; 25,000 km/h)":

  • {{convert|24|Mach|240,000|sigfig=2}} → Mach 24 (25,000 km/h; 16,000 mph) [as in Scramjet]

Can use &minus; for a minus sign, but it gives invalid results:

  • {{convert|-4|km}} → −4 kilometres (−2.5 mi) [correct]
  • {{convert|&minus;4|km}} → −4 kilometres (−2.5 mi) [spurious "4,000,000"]

Negative numbers can give rounding inconsistency:

  • {{convert|1200|m|ft}} → 1,200 metres (3,900 ft) [correct]
  • {{convert|-1200|m|ft|-2}} → −1,200 metres (−3,900 ft) [correct]
  • {{convert|-1200|m|ft}} → −1,200 metres (−3,900 ft) [inconsistent]

Specifying sigfig in a range can give an expression error:

  • {{convert|0|-|10|m|ft|2}} → 0–10 metres (0.00–32.81 ft) [correct]
  • {{convert|0|-|10|m|ft|sigfig=2}} → 0–10 metres (0.0–33 ft)

Specifying disp=5 with an output combination can give an expression error:

  • {{convert|3|st|lb kg}} → 3 stone (42 lb; 19 kg) [correct]
  • {{convert|3|st|lb kg|disp=5}} → 3 stone (40 lb; 20 kg)*

Can get incorrect output values when converting certain values with a multiple output unit. In the first of the following, 152.4 m is exactly 500 feet, and that value is somehow interpreted as zero and omitted.

  • {{convert|152.4|m|ftin}} → 152.4 metres (500 ft 0 in)
  • {{convert|304.8|m|ftin}} → 304.8 metres (1,000 ft 0 in)
  • {{convert|1|ch|ftin}} → 1 chain (66 ft 0 in)
  • {{convert|42|ft|ftin}} → 42 feet (42 ft 0 in)
  • {{convert|3,175.14659|kg|stlb}} → 3,175.14659 kilograms (500 st 0 lb)
  • {{convert|0.22321428571429|LT|lboz}} → 0.22321428571429 long tons (500 lb 0 oz)

Consistency problems

[edit]
  • {{convert|1230|m3/s}} → 1,230 cubic metres per second (43,000 cu ft/s) [correct]
  • {{convert|1.23|e3m3/s}} → 1.23 thousand cubic metres per second (43×10^3 cu ft/s) [missing "per second"]

  • {{convert|1+1/2|in|mm|abbr=on|disp=or}}1+12 in or 38 mm [correct]
  • {{convert|1+1/2|in|mm|abbr=on|disp=or|lk=on}}1+12 in or 38 mm [bad fraction]
  • {{convert|1+1/2|in|mm|abbr=on|disp=or|lk=out}}1+12 in or 38 mm [bad fraction]
  • {{convert|1+1/2|mi|0|chain|km}}1+12 miles 0 chains (2.4 km) [bad fraction]

  • {{convert|18|in|cm|disp=output only}} → 46 cm [correct]
  • {{convert|1|ft|6|in|cm|disp=output only}} → 46 cm [assumes abbr=off]

  • {{convert|18|in|cm|disp=flip}} → 46 centimetres (18 in) [correct]
  • {{convert|1|ft|6|in|cm|disp=flip}} → 46 centimetres (1 ft 6 in) [does not "flip" abbr]

  • {{convert|4500|acre ft|e9USgal e6m3}} → 4,500 acre-feet (1.5×10^9 US gal; 5.6×10^6 m3) [correct—"US gal"]
  • {{convert|4500|-|4900|acre ft|e9USgal e6m3}} → 4,500–4,900 acre-feet (1.5×10^9–1.6×10^9 US gal; 5.6×10^6–6.0×10^6 m3) [just "gal"]

  • {{convert|1/3|mi|km}}13 mile (0.54 km) [plural "miles"]
  • {{convert|1/3|mi|km|disp=or}}13 mile or 0.54 kilometres [singular "mile"]
  • {{convert|0.4|m|ft|abbr=off}} → 0.4 metres (1.3 feet) [plural "feet"]
  • {{convert|0.4|m|ydft|abbr=off}} → 0.4 metres (1.3 feet) [singular "foot"]

  • {{convert|0.1|-|0.2|m}} → 0.1–0.2 metres (3.9 in – 7.9 in) [space after dash]

  • {{convert/spell|8|ft|m|abbr=off|sp=us}} → {{convert/spell|8|ft|m|abbr=off|sp=us}} ["metres" should be "meters"]

Convert/3 and convert/4 ignore precision parameter.

  • {{convert/3|12.34|by|23.45|by|34.56|km|mi}} → {{convert/3|12.34|by|23.45|by|34.56|km|mi}} [correct]
  • {{convert/3|12.34|by|23.45|by|34.56|km|mi|1}} → {{convert/3|12.34|by|23.45|by|34.56|km|mi|1}} [ignores precision "1"]
  • {{convert/4|12.34|by|23.45|by|34.56|by|45.67|km|mi|1}} → {{convert/4|12.34|by|23.45|by|34.56|by|45.67|km|mi|1}} [ignores precision "1"]

Other issues

[edit]

No error checking for conversions between units of different types:

Incorrect error message before result:

Negative zero in result:

  • {{convert|-18|C}} → −18 °C (0 °F)

Redundant input can give a fraction glitch:

  • {{convert|0+3/8|mi|m}}0+38 mile (600 m)

Template problem gives {{{n}}} in output:

  • {{convert|15|to|32|mpgus|l/100 km mpgimp}} → 15 to 32 miles per US gallon (15.7 to 7.4 l/100 km; 18 to 38 mpg‑imp)

Template problem gives error message:

  • {{convert|1|to|10|USgal/d}} → 1 to 10 US gallons per day (4.4×10−8 to 4.38×10−7 m3/s)

Rounding input sometimes fails. Currently, the second of these gives the correct output, but shows several lines of error messages for the input.

  • {{convert|12345.45|m|ft|adj=ri1}} → 12,345.5 metres (40,503.4 ft) [correct]
  • {{convert|123456.45|m|ft|adj=ri1}} → 123,456.4 metres (405,040.8 ft)

Minor issues

[edit]

Some minor consistency and other issues are shown in the following table which shows results from the module and the template.

Issue Convert Module Template
"miles" {{convert|0.6|mi|km}} 0.6 miles (0.97 km) 0.6 miles (0.97 km)
"mile" {{convert|0.6|mi|km|disp=x| (|)}} 0.6 miles (0.97 km) 0.6 miles (0.97 km)
"inches" {{convert|1/2|in|cm}} 12 inch (1.3 cm) 12 inch (1.3 cm)
"inches" {{convert|1/2|in|cm|abbr=off}} 12 inch (1.3 centimetres) 12 inch (1.3 centimetres)
"inch" {{convert|1/2|in|cm|abbr=out}} 12 inch (1.3 cm) 12 inch (1.3 cm)
"ha" {{convert|1032900|acre|sqmi ha|lk=on}} 1,032,900 acres (1,613.9 sq mi; 418,000 ha) 1,032,900 acres (1,613.9 sq mi; 418,000 ha)
"ha" {{convert|1032900|acre|sqmi ha km2}} 1,032,900 acres (1,613.9 sq mi; 418,000 ha; 4,180 km2) 1,032,900 acres (1,613.9 sq mi; 418,000 ha; 4,180 km2)
"hectares" {{convert|1032900|acre|sqmi ha km2|lk=on}} 1,032,900 acres (1,613.9 sq mi; 418,000 ha; 4,180 km2) 1,032,900 acres (1,613.9 sq mi; 418,000 ha; 4,180 km2)
2 is precision {{convert|10|ft|m|2|disp=x| [|]}} 10 feet [3.05 m] 10 feet [3.05 m]
missing "]" {{convert|10|cc|ml|disp=x| [|]}} 10 cubic centimetres [10 ml] 10 cubic centimetres [10 ml]
{{{n}}} {{convert|26|-|32|mpgus}} 26–32 miles per US gallon (9.0–7.4 L/100 km; 31–38 mpg‑imp) 26–32 miles per US gallon (9.0–7.4 L/100 km; 31–38 mpg‑imp)
invalid input {{convert|1.234.567|ft|m}} [convert: invalid number] [convert: invalid number]