Template talk:Convert/Archive September 2016

Conversion to inches: fractions, avoiding unnecessary decimals
I have been modifying the unit conversions in articles on trees (working through List of Minnesota trees by scientific name). I am using the frac parameter, because tenths, hundredths, and thousandths of inches are meaningless to me and probably other people in the US; rulers are marked in fractions by powers of two. I have no idea how much 0.39 inch is, but I can understand $3/8$ inch. See for instance this article when it had decimals in the Description section and then after I converted it to fractions

I wonder if it would be possible to make fractions the default, or at least make a setting that would automatically choose the appropriate fraction. For centimeters, I have been using $1/4$ inches; for half-centimeters or millimeters rounded to 5, $1/8$ inch; for millimeters, $1/16$ inch; for half-millimeters, $1/32$.

It would also be nice if measurements rounded to five or ten centimeters were automatically displayed as whole inches (rather than tenths of inches), because one inch is almost exactly 2.5 centimeters. It is annoying to have to specify a precision of 0 every time that a number like 10 cm gets converted to 3.9 inches rather than simply 4 inches.

I was thinking maybe either fractions could be the default when converting from cm or mm to inches, or there could be a default setting for the frac (default?) that would use a standard set of equivalencies similar to the one I mentioned above. — Eru·tuon 22:33, 3 September 2016 (UTC)


 * One inch is defined as 2.54 cm. Fractions are never used with metric. I think we are running up against the olde measurements being nearly obselete, but this conversion should not be the default. In other contexts we want the decimal form eg. QF 3.7-inch mountain howitzer or 9.45-inch Heavy Mortar. There is no reason to believe that the fractional form is preferred, when so few people think in chains or furlongs anymore. Hawkeye7 (talk) 23:16, 3 September 2016 (UTC)
 * Inches and feet may be almost obsolete in Australia, but not in the United States. Hmm, I suppose I am not being very clear. I am proposing that fractions of inches be used when cm or mm are converted to inches. Of course fractions of cm and mm are never used. — Eru·tuon 23:34, 3 September 2016 (UTC)
 * Despite having used fractions of an inch all my life, I wouldn't support using them in a modern encyclopedia, other than in very specialised areas. Fractions are probably losing traction throughout most fields because of the use of calculators and computers which do routine calculations in decimal format by default. I've used A/F spanners for over 50 years, but I'd still have to think carefully to work out that a $21/32$ nut is 50% wider than a $7/16$ one. It's pretty obvious that 660 thou is 50% bigger than 440 thou, though. --RexxS (talk) 23:50, 3 September 2016 (UTC)
 * Then, I retract my proposal of making it the default (used whenever you type ). It would, however, be helpful if there were an option like default that could be used in articles on plants. I suppose the parameter name would have to be different: obviously the default would be to convert to decimals... — Eru·tuon
 * I suppose you know that you can force fractions as output like this:  -> 0.5 cm ? It's documented at Template:Convert/doc  and might be usable, even if it's not precisely what you want. --RexxS (talk) 00:26, 4 September 2016 (UTC)
 * That's what I have been using (see for instance ), and it works well, but it is a bit laborious, since I have to decide which denominator to use. It would save time if I could simply input the same parameter into all conversion templates. ([edit:] It would also standardize the behavior, and if the standardization was done right, give a good result every time even when used by an unskilled editor.) — Eru·tuon 00:52, 4 September 2016 (UTC)
 * Sorry, I should have read your original post more carefully. What you'd like is to have auto-selection of the value of frac, rather than a default? I'd have suggested something like auto leading to a lookup for the value for frac. Would you want a scheme like: if 'val' is the input value, then: val > 1cm -> 4; 1cm > val > 5mm -> 8; 5mm > val > 1mm -> 16; 1mm > val -> 32? Or is it the least significant figure in the value that should determine the denominator? Either way, it should be feasible. How many articles would benefit from this feature, do you think? --RexxS (talk) 02:32, 4 September 2016 (UTC)
 * Yes, that sounds like what I mean. auto would be a better label. Yes, I use the least significant figure, and determine if the value has a significance of 5, 1, 0.5, or 0.1. 1.5-3.5 cm (15-35 mm) would have a significance of 0.5 cm (5 mm), and I would use 8. But 1.4-3.6 cm (14-36 mm) would have a significance of 0.1 cm (1 mm) and I would use 16 (though probably I should be using 32). I would take 13-15 mm as significant to 1 mm, though, because the first number is not rounded to 5. Does that make sense of my process?


 * Articles about plant species that have measurements would benefit. I don't know how many there are, but there must be thousands of articles on plant species, some fraction of which have measurements. At least several hundreds. (Perhaps an accurate count would be obtained if one could determine which articles have Taxobox with Plantae and convert with the cm or mm parameters.) — Eru·tuon 03:38, 4 September 2016 (UTC)

@Casliber: You write botanical articles and I think I've seen you use converts with fractions such as. Do you have a comment on the proposal that convert should support  to automatically determine the denominator from the precision of the value? If implemented, it would allow  and convert would guess whether the denominator should be 2, 4, 8, 16, or some higher power of 2. Bear in mind that convert currently reduces the fraction, for example, if a value would be $1 8/16$ it is actually displayed as $1 1/2$. I suppose some (historic?) engineering specification might use $1 8/16$ to suggest the precision, but I don't think convert should do that. Unfortunately the rounding/precision part of convert is among its trickiest code, and a very clear mind would be needed to work out how to implement this—I imagine there would be some awful corner cases, including things like: Johnuniq (talk) 04:44, 4 September 2016 (UTC)
 * → 83.2 to 161.6 cm
 * The only problem I see is intuiting some cases where one would use only a 1/2 inch - I'd hate to see small fractions used there. So I'd be wary of coding like that unless it had some other feature countering that. Cas Liber (talk · contribs) 10:59, 4 September 2016 (UTC)

Output nothing for sample converts using NNNN
Some templates call convert and provide samples like. If "NNNN" is not replaced with a valid number, convert currently outputs an error message. Instead, the sandbox module outputs nothing. I am planning to include that in the next release (soon). Johnuniq (talk) 07:52, 24 September 2016 (UTC)
 * Example:  → Example:
 * I've done a bit more checking. The only examples I had seen used "NNNN" (four N), but searching found a couple of templates using "NNN" (three N). I plan to take three or more "N" as an indication that convert should output nothing. Johnuniq (talk) 09:47, 25 September 2016 (UTC)

Unabbreviated something something request
I have no idea how to title this request. In astronomy/space exploration articles (and, perhaps, elsewhere), it is often desirable to have vast numbers converted, but you don't want all the zeroes, nor do you always want exponential notation, just for the sake of readability and easy comprehension. I've been taking to doing this: This is nice, at least for the first instance of a measure, but it gets long on the eyes after a while. What I'd like is to keep the written out "million", "billion", etc, but abbreviate the unit. In other words, something like: That is nice and simple and easy on the eyes and on the editor. I'd thank you from the bottom of my wee heart if this could be done.
 * 280 e6km to obtain 280 e6km
 * 280 e6km to obtain 280 million km (170 million mi; 1.9 AU)

P.S.: This is not part of this request, necessarily, just a curiosity about something I would like to see available but don't know if its possible. Using the above example, if a source only gives the measurement in miles, but for standardisation we want kilometers first, but also want AUs represented, would it be feasible to re-jigger the flip to select which unit comes first...or, possibly easier, create a parameter akin to km to do the job? For example:
 * 170 e6mi to obtain 280 million km (170 million mi; 1.9 AU)

Anyway, uh, yay conversions! — Huntster (t @ c) 00:50, 14 September 2016 (UTC)


 * So your second request seems so reasonable that this almost seems like a bug to me. If I say order=flip and there are multiple output units I would expect to see what you're asking for. Why would we ever want the current behavior, which produces this: 170 e6mi ? Kendall-K1 (talk) 01:36, 14 September 2016 (UTC)
 * I second that. "unit; unit (unit)" is clunky and bizarre. — Eru·tuon 01:49, 14 September 2016 (UTC)

Having a choice with order=flip was discussed at Template talk:Convert/Archive June 2016 with order=N being suggested (and I wondered about order=0 to suppress the source unit as wanted for some converts). Re "million", as people here probably know, the current situation is that it's "million" when the unit is not abbreviated, and scientific notation when it is. Examples: I'll try to think about the issues raised next week. Johnuniq (talk) 07:48, 14 September 2016 (UTC)
 * → 280 e6km
 * → 280 e6km
 * → 280 e6km

@Huntster: I have put  in the sandbox, examples: Please test and check it does what is wanted. I know someone is going to want "million miles" but I'll wait for that, along with a suggestion for the syntax. I'm still pondering  but that one is very tricky, and more than the OP is needed per the June 2016 discussion I linked above. Johnuniq (talk) 05:14, 19 September 2016 (UTC)


 * , yep, I put unit through some paces, and it worked perfectly. Outstanding! If they want "million miles" spelled out, then they can use off like I did. Regarding the flip, I fully admit I have no idea how the code works, but would it be possible to simply specify, say, km to force kilometers first, or mi to force miles first, etc etc? As in, rather than the code trying to figure out what the user is wanting with "flip", make the user specify what they want for non-standard cases. I'm just spitballing due to ignorance, of course. — Huntster (t @ c) 07:57, 19 September 2016 (UTC)

That's good, but more may be needed. The earlier discussion wanted something to handle, for example, a table where some entries have a reference in one unit, while others use a second unit, and still others use a third. That is, some converts would use one unit for the input, while others would have different input units. However, convert would display each item with consistent units. The following example is contrived but shows the idea. Unit position for order=N:                          0                1          2       3       4 100 kPa         → 100 kilopascals (750 Torr; 0.99 atm; 15 psi; 30 inHg) 750 Torr → 100 kilopascals (750 Torr; 0.99 atm; 15 psi; 30 inHg) 0.99 atm → 100 kilopascals (750 Torr; 0.99 atm; 15 psi; 30 inHg) 15 psi  → 100 kilopascals (750 Torr; 0.99 atm; 15 psi; 30 inHg) 30 inHg  → 100 kilopascals (750 Torr; 0.99 atm; 15 psi; 30 inHg) The suggested syntax was order=N where N is a number as above. I'm thinking about that, but convert has a lot of peculiarities which complicate the code. Another discussion wanted the ability to omit the input unit because, for example, a reference might use PS but the table wants to display some other units. I'll report back in a few days. Johnuniq (talk) 10:26, 19 September 2016 (UTC)


 * Well, you know best certainly, but oh boy that sounds unreasonably complicated, from both a code and an end-user standpoint. — Huntster (t @ c) 20:34, 19 September 2016 (UTC)


 * Would it make sense to tackle the simpler, more common case first? order=flip with two output units should produce "unit (unit; unit)" instead of "unit; unit (unit)". Kendall-K1 (talk) 21:10, 19 September 2016 (UTC)

order=unit numbers
What if order could contain a series of numbers that specified which of the units should be displayed and in what order? 1 would represent the input unit, 2 the output unit, and 3 and 4 the optional second and third output units. Then if you input  and you only wanted to display the last three, you could add 234. Or if you input, you could add 21 as an alternative to flip. — Eru·tuon 18:16, 25 September 2016 (UTC)
 * Possibly, but very few people would want to figure out that kind of syntax. I thought it was more obvious to just list the units that are wanted as the output. Johnuniq (talk) 02:13, 26 September 2016 (UTC)

order=out
@Huntster, Jimp: I put a test of a new system in the sandbox to implement your suggestions although I am experimenting with a different syntax. I'm pretty sure some options will fail with the new system, and I will either fix them or disable use of those options when the new syntax is used.

While Huntster may have a different aim, the main objective was to easily make tables where, for example, one reference might give a value in km, while another gives a value in miles, and other references use other units. The option  replaces the input with the first unit in the output combination—the order of the units displayed is determined by the output combination used in the convert. Examples:

In the above, the inputs use different units but each result shows the same units. The input unit in the last example (nautical miles) does not appear in the output. That would be useful if a reference specified an unwanted unit.

Examples based on previous suggestions follow. Thoughts? Johnuniq (talk) 10:03, 21 September 2016 (UTC)


 * , very interesting. Even if practical application is fairly limited, I especially like the flexibility of an input measure that can be entirely excluded from the output. I'm at work right now and cannot get too involved with testing, but I'll try to run a gamut of tests tonight. — Huntster (t @ c) 15:41, 21 September 2016 (UTC)


 * That looks great, very simple & straight forward. Jimp 08:27, 25 September 2016 (UTC)

Using  is not useful with some options. I am recording this for future reference. Johnuniq (talk) 10:57, 25 September 2016 (UTC)
 * Spelling (for example, ) is disabled.
 * The option  (show input unit symbol as well as name) is disabled.
 * The following shows some options without  to show normal operation. This uses fixed wikitext so the output will not change in the future.
 * → 78 inches (2.2 yd; 6.5 ft; 200 cm)
 * → 2.2; 6.5; 200
 * → inches
 * → yd; ft; cm
 * → 2.2 yd; 6.5 ft; 200 cm
 * The following shows the same converts using . Some of the results may be unexpected. These combinations of options are not intended to do anything useful; this shows what happens.
 * → 2.2 yards (6.5 ft; 200 cm)
 * → 2.2 (6.5; 200)
 * → inches
 * → yards (ft; cm)
 * → 2.2 yards (6.5 ft; 200 cm)


 * I particularly like the one whose only output is the word "inches." I'm trying to think where I can use this... Kendall-K1 (talk) 17:50, 25 September 2016 (UTC)
 * I did say it wasn't useful! The same result comes from  and that has worked for years. Presumably disp=unit is for more exotic units where getting the formatting of the unit name might not be easy. I was just testing what the unusual options do with the new order=out. Johnuniq (talk) 02:10, 26 September 2016 (UTC)

Module version 15
Some changes to the convert modules are in the sandbox, and I intend switching the main modules to use the sandbox soon.

The changes are:
 * Units minor changes/additions:
 * will now show plural "leagues" with  (like  ). Discussion here.
 * is a new unit with symbol R☉, and the existing  now has symbol M☉ (italic "M"). Discussion here with follow-up here.
 * New range  for a table of high/low temperatures such as  . Discussion here. Example:
 * Convert will output an empty string if the first input value is "NNN"—three or more "N". Some infoboxes (example) have documentation with samples including converts like . This change allows the samples to be copied into an article without displaying an error. Discussion here.
 * New  option. Using   abbreviates all units and number names;   abbreviates only units. Discussion here. The following examples have both options to show the difference.
 * The suppression of overlinking is improved. This was possible due to changes required to implement . The only differences for converts in articles as at June 2016 occur with the following:
 * The previous version (before September 2016) output the following for these converts.
 * 115 lb (52 kg; 8 st 3 lb)
 * 25 kilograms (55 lb; 3 st 13 lb)
 * 1,500 lb/h (680 kg/h)
 * 15 kWh/m2 (4,755 BTU/sq ft; 5.017 MJ/sq ft)
 * New  option. Discussion here. Using   swaps the entire left-hand and right-hand sides, which is not helpful when the output is a combination. This uses fixed wikitext so the output will not change in the future.
 * → 2.4 yards; 2.2 metres (86 in)
 * Using, the order in which units are displayed is set by the output unit. The input unit can be repeated in the output, or can be omitted if it is not wanted.
 * The previous version (before September 2016) output the following for these converts.
 * 115 lb (52 kg; 8 st 3 lb)
 * 25 kilograms (55 lb; 3 st 13 lb)
 * 1,500 lb/h (680 kg/h)
 * 15 kWh/m2 (4,755 BTU/sq ft; 5.017 MJ/sq ft)
 * New  option. Discussion here. Using   swaps the entire left-hand and right-hand sides, which is not helpful when the output is a combination. This uses fixed wikitext so the output will not change in the future.
 * → 2.4 yards; 2.2 metres (86 in)
 * Using, the order in which units are displayed is set by the output unit. The input unit can be repeated in the output, or can be omitted if it is not wanted.
 * Using, the order in which units are displayed is set by the output unit. The input unit can be repeated in the output, or can be omitted if it is not wanted.

The  option may not be used often, but it solves two problems that have been raised in the past: Release notes for earlier versions are listed here. Johnuniq (talk) 04:54, 26 September 2016 (UTC)
 * When preparing tables of measurements (for example, lengths of rivers), one reference might give a value in km, while another gives a value in miles, and other references use other units. Using, the wikitext for each convert would be exactly the same except for the input—the input value and unit would depend on the reference.
 * Sometimes the unit used in the reference is not wanted in the result (for example, as discussed here). For example:


 * , very very cool. Thanks for all your hard work! — Huntster (t @ c) 14:26, 26 September 2016 (UTC)
 * Thanks seconded, especially for unit which is just what I was looking for a few days ago -- how did you guess? — JFG talk 09:31, 27 September 2016 (UTC)
 * Thanks all, version 15 is now live. Johnuniq (talk) 07:53, 28 September 2016 (UTC)

Can this be made to work?
For Intermodal container, 8 x 8 x would work. 35 0 35 0 and 35 ft 35 ft would not. Peter Horn User talk 17:21, 28 September 2016 (UTC)


 * Template doc says "While it is possible to enter feet, inch in a simple conversion, this is not possible for ranges [and multiples]". But maybe something along these lines? 8 x 8 x Kendall-K1 (talk) 17:42, 28 September 2016 (UTC)
 * 8 x 8 x which is the reverse of 8 x 8 x. Peter Horn User talk 18:03, 28 September 2016 (UTC)


 * I think the following is what is wanted, except it has a small problem:
 * → 8x8.5x35 ft
 * The small problem is that it shows two "0 in" when it would be cleaner if they were omitted. Unfortunately that can't be avoided. The trick of using order=out does effectively allow an input multiple unit like 8 feet 6 inches to be used in a range, but it won't cover everything wanted.
 * By the way, the  used above is ignored. The fact that   is used means that only the output will appear. Except, if only one output unit is used, order=out does not make sense, and it is ignored. In that case disp=out does have an effect. For example:
 * → 42 in
 * → 42 in
 * Johnuniq (talk) 07:48, 29 September 2016 (UTC)

Slash with thin spaces
Could thin spaces be added around the slash range separator? I tried that at Module:Sandbox/Erutuon/Temperature arrays/doc and I think it's more readable than an unspaced slash. — Eru·tuon 03:20, 30 September 2016 (UTC)
 * without thin space (current behavior):
 * with thin space:
 * We spent two weeks discussing that in August!
 * I changed the sandbox module to output a thin space around the slash. Please check the result and ask at the wikiproject and get someone to agree.
 * For testing, I added  (two slashes) which outputs an unspaced slash like the main module does now with a single slash. The double-slash range will be removed—it's just to allow quick comparisons of the two outputs:
 * → 12/20 °C (54/68 °F)
 * Johnuniq (talk) 04:27, 30 September 2016 (UTC)
 * Your examples look good to me. I should've thought of it before; I guess I was just looking for a quick solution at the time. I posted at WP:METEO, and said it looks fine. Probably no one will object. — Eru·tuon 05:09, 30 September 2016 (UTC)
 * I have yet to check how it shows up with mobile interfaces, but at least the way it currently appears for me (FYI, I am using a desktop), I agree that the spaced version is a bit more legible. Dustin  ( talk ) 05:13, 30 September 2016 (UTC)
 * I have yet to check how it shows up with mobile interfaces, but at least the way it currently appears for me (FYI, I am using a desktop), I agree that the spaced version is a bit more legible. Dustin  ( talk ) 05:13, 30 September 2016 (UTC)

I updated the module so it outputs thin spaces around the slash. It is still possible to use "//" with convert/sandbox but that will be removed in due course. I replaced the example above with fixed wikitext so it won't break when "//" is removed. The thin space looks good at Climate of California and Climate of Spain. Johnuniq (talk) 23:34, 30 September 2016 (UTC)