Template talk:Convert

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Frequently asked questions (FAQ)
Q: When using {{convert}} why does the answer not seem right sometimes?
A: This template takes into account the precision of the supplied value and generally rounds the output to the same level of precision. If you need to change from the default output precision, see Help:Convert.
Q: What are all the possible units (kg, lb, m, cm, ft, in, °C, °F, km, mi, nmi, mph, km/h, and so on)?
A: See: Help:Convert units.
For more, see the FAQ.

Rounding to multiples of 5 (or 25) and fractions of 5 (or 25)[edit]

eg using {{convert|7|to|8|ft|m|1|round=5}} (or similar) I would like the output to be 7 to 8 feet (2 - 2.5 m) not 7 to 8 feet (2.1 to 2.4 m)


{{convert|3.5|mi|km|sigfig=2|round=5}} to be 3.5 miles (5.5 km) not 3.5 miles (5.6 km)

Help pls Cinderella157 (talk) 07:49, 9 November 2016 (UTC)

@Cinderella157: The first issue has an easy solution, use to(-). The second is a bit more involved. There is a conflict between sigfig=2 (output has 2 significant figures) and round=5 (output rounded to the nearest multiple of 5). The first convert is also invalid because 1 means the output is rounded to 1 decimal place, and that conflicts with round=5. Convert will use one of the rounding alternatives provided and will ignore the other.
Try these:
  • {{convert|7|to(-)|8|ft|m|round=5}} → 7 to 8 feet (0–0 m) (see below)
  • {{convert|7|to(-)|8|ft|m|round=0.5}} → 7 to 8 feet (2–2.5 m)
  • {{convert|3.5|mi|km|round=0.5}} → 3.5 miles (5.5 km)
The first convert gives zero as the output because 7 feet is 2.13 m, and 8 feet is 2.44 m. Those values round to zero with round=5. Johnuniq (talk) 09:58, 9 November 2016 (UTC)

@Johnuniq many thanks Cinderella157 (talk) 07:10, 10 November 2016 (UTC)

Roman mile[edit]

Could someone please add Roman miles to the length? A roman mile is equal to about 4851 feet. Thanks. Iazyges Consermonor Opus meum 05:55, 17 November 2016 (UTC)

@Iazyges: Are you sure that would be helpful? As expected, Ancient Roman units of measurement and Mile#Roman mile have only vague statements about what a Roman mile is, with varying rules. I have found sizes.com to have good information, and it says "Somewhere between 1471 and 1485 meters", and also "a well-accepted guess at the length of the mille passus in Roman Britain is about 1,479.5 meters [4,854.0 ft]". If an historical document specifies dimensions in Roman miles, it may be misleading to convert the values as if a precise conversion factor were known. What articles would benefit from an automated conversion? Johnuniq (talk) 06:53, 17 November 2016 (UTC)
@@Johnuniq: Roman ones in general, largely milhist, as the distances for marches, and the distances in treaties are well recorded, along with ancient geography. I would probably go with the 4854 feet as a roman mile. Iazyges Consermonor Opus meum 07:12, 17 November 2016 (UTC)
I guess that what is probably needed is a one-way conversion that yields something like 100 Roman miles (about 92 mi; 148 km). I can see that historical accounts would benefit from having a conversion that allowed readers to conveniently visualise such distances. Nevertheless, as Johnuniq says, we shouldn't be implying a precision that is greater than the uncertainty in the conversion factor (around 1%), so the use of such a conversion would have to be carefully done, otherwise I foresee nonsense like 105 Roman miles (96.53 mi) - or even (509,670 ft). --RexxS (talk) 18:18, 17 November 2016 (UTC)
It would be cool if the template knew the uncertainty in the conversion. It could then insert the "about" modifier, and refuse to accept a sigfig= (or an implied sigfig) greater than the uncertainty. I was thinking about this recently in connection with Ton of refrigeration, which has no exact conversion to SI units. I'm quite certin Johnuniq will eagerly rush to implement this. Kendall-K1 (talk) 18:43, 17 November 2016 (UTC)
Forgive my lack of experience with templates like these (most of my work is in a usercheck I have made, and some others), how would the "about" code be implemented, would it be a range such as 1 roman mile (1471-1485 metres) or would it be 1 roman mile (c. 1481 metres)? Iazyges Consermonor Opus meum 21:55, 17 November 2016 (UTC)
(not an answer...). You are forgiven right away! The topic of rounding, precision, about, significant digits, nearest 5, /doc#Rounding, etc.: this is the most complicated topic of this template {{convert}}. To get a taste, just see section #Faulty_mathematics above. So many issues are involved. For starters: how exact was the original measurement? How to round (how many digits after decimal sign) when converted say meter into ft? Welcome to this. -DePiep (talk) 22:10, 17 November 2016 (UTC)
One problem is that until the time of agrippa, one mile was defined as 1000 legions paces, so if the legion was tired a mile could be 2 thousand feet, if they werent it could be almost double that. We do know that it was exactly 5000 roman feet, and the roman foot is 97% of a normal foot, so I propose setting it as "About 4850 feet". Iazyges Consermonor Opus meum 22:17, 17 November 2016 (UTC)
I should probably have attached a smiley to my comment (although many people don't know what that means any more). The pitfalls are so numerous that I doubt we could agree on how the "about" feature would work, much less how to implement it. Kendall-K1 (talk) 22:24, 17 November 2016 (UTC)

I added the unit romi as an experiment. When convert is next updated (probably months from now) I will have a look at how the unit is used. If it appears to be useful (and subject to discussion here), we can keep it. Otherwise, the unit can be removed. I used the 1,479.5 meters [4,854.0 feet] "well-accepted guess at the length of the mille passus in Roman Britain" from sizes.com as above. I suspect romi will not be particularly useful as described above, but we can see. Examples:

  • {{convert|100|romi}} → 100 Roman miles (150 km; 92 mi)
  • {{convert|100|romi|m}} → 100 Roman miles (150,000 m)
  • {{convert|100|romi|abbr=on}} → 100 Roman miles (150 km; 92 mi)

The last example shows that there is no symbol for the new unit. I picked km mi for the default output because that is what other units like admi (admirality mile), AU (astronomical unit), and nmi (nautical mile) do. Johnuniq (talk) 00:37, 18 November 2016 (UTC)

Thanks! Iazyges Consermonor Opus meum 00:48, 18 November 2016 (UTC)


What happened to UStsp? I could swear it used to work, but it is now an unknown unit. It's talked about at Template talk:Convert/Archive July 2013#Changes to modules require reformat of million articles as if it had been implemented. I was going to use it at List of IBA official cocktails#List of sweetened products. Kendall-K1 (talk) 21:53, 28 November 2016 (UTC)

Is there a UKtsp? Or has that become EUtsp? Martinevans123 (talk) 22:00, 28 November 2016 (UTC)
Template:Convert/UStsp was created at the same time as the accompanying post at talk in July 2013 to show the flexibility of the old templates (Module:Convert was used to replace the old templates in December 2013). I do not know why the template gives these results:
  • {{convert/old|1|UStsp}} → 1 US teaspoon (4.9 ml)
  • {{convert/old|4.9|ml|UStsp}} → 4.9 millilitres (2.4×10−11 US tsp)
The module has never defined a teaspoon unit because no article has ever needed it. One problem is that it is a vague measurement whose meaning has changed, although there are now arbitrary definitions (Teaspoon#Measure of volume). Two tablespoon units are defined: AUtbsp (not used*) and UStbsp (used only in David Blaine*). (* The usage information is from June 2016.) If teaspoon units would be useful in some articles, they can be added, but please work out where they would go before adding them. The symbol would be UStsp, name US teaspoon, and default output ml? Unfortunately editors would have to add sp=us if that was wanted (if "milliliters" is being displayed). Johnuniq (talk) 22:51, 28 November 2016 (UTC)
I was thinking I shouldn't be lazy and should add UStsp as a trial, but the intended conversion is:
4 US teaspoons, or 23 US fluid ounces
That is exactly correct by (modern) definition, and convert could do something that looked the same, but is it worthwhile? According to sizes.com, the FDA defines a UStsp as exactly 5 ml, rather than the conventional 4.929 ml (approx). The problem is that once a unit is added to convert, editors will believe it is accurate without knowing the vagaries involved. Johnuniq (talk) 23:32, 28 November 2016 (UTC)
There are actually two different US teaspoons. The traditional one is 4.9 ml, but that wasn't confusing enough so the FDA defined a new teaspoon called the "food labeling teaspoon" that is exactly 5 ml. Same thing with the ounce, which now comes in both 28 and 30 g sizes.
I don't really need the UStsp conversion. This is the first time I've had the urge to use it in many years of adding conversions to articles, and this one already has a manual conversion in it. And of course the fraction would be a problem anyway. I'm mostly just asking because I thought I remembered seeing it before and wanted to know if my memory is failing. Kendall-K1 (talk) 00:51, 29 November 2016 (UTC)

Nautical mile precision[edit]

{{convert|100|nmi|km|adj=on}} gives an incorrect result (100-nautical-mile (190 km)), to get the correct result {{convert|100|nmi|km|sigfig=4|adj=on}} (100-nautical-mile (185.2 km)) --- can this be fixed? ESAD-Hooker (talk) 02:49, 10 December 2016 (UTC)

The template is designed to detect the apparent number of significant figures in the input, and provide a similar number of significant digits in the output. If the input is more precise than is apparent, the editor needs to specify how many significant figures there are with |sigfig=. So there is nothing wrong. Jc3s5h (talk) 03:04, 10 December 2016 (UTC)