Template talk:Convert

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

... in conception
... and in reality

Bug report: error in converting liters to US fl oz[edit]

The tool reports incorrect values:

4.0 litres (140 imp fl oz; 140 US fl oz)

This should be 135 US fl oz.

A conversion from 4 should be less than 4.05:

4.05 litres (143 imp fl oz; 137 US fl oz)


I'm not sure where else to report this. kslays (talkcontribs) 09:36, 7 March 2024 (UTC)[reply]

That is unfortunate but it happens because convert is guessing the number of significant figures in the input value. Convert does a good job most of the time but it fails in situations like this and the only cure is to specify the wanted precision. That is most easily done with a number that specifies the number of fractional digits after rounding, but sigfig and round are also options: see the rounding documentation on the template page and the first question in the FAQ at the top of this page. Johnuniq (talk) 10:29, 7 March 2024 (UTC)[reply]
That's very helpful, thanks. I was able to fix the article I was working on with sigfig, since I don't think round accepts a value to round to whole numbers. kslays (talkcontribs) 21:13, 7 March 2024 (UTC)[reply]
  • Too late now, but in retrospect a better design would have been to require specification of sigfigs or something. The guessing / default just causes too many headaches. EEng 22:02, 7 March 2024 (UTC)[reply]

Unitless numbers; %, ‰, ppm, ppb, etc.[edit]

I'd like to add unitless scales (%, ppm, ppb, etc.). Mostly this would be for thermal expansion coefficients. Sometimes people write "10.5 μin/(in⋅°F)", and I'd like to be able to convert it to

  • "18.9 ppm/°C" (preferentially)
  • "18.9 × 10−6/°C"
  • "18.9 μm/(m⋅°C)".

The latter one is actually pretty straightforward to add, I think. But the 1st two outputs don't seem possible at the moment. From what I can tell, {{convert}} needs an input unit and an output unit. Unit cancellation doesn't seem to be able to produce (or even consume) unitless values.

How can I specify 'ppm', 'ppb', etc., as unitless scale values (i.e., essentially equal to 10−6, 10−9, ...)?  — sbb (talk) 20:13, 24 March 2024 (UTC)[reply]

The trick is to think in terms of what convert does know - in this case it's the /F and /C. The rest is just ornamentation.
{{cvt|10.5|/F|/C||adj=pre|ppm|disp=preunit|ppm}} → 10.5 ppm/°F (18.9 ppm/°C)
{{cvt|10.5|/F|/C||adj=pre|ppm|disp=preunit|× 10<sup>−6</sup>}} → 10.5 ppm/°F (18.9 × 10−6/°C)
Not sure how to do the last one.  Stepho  talk  23:14, 24 March 2024 (UTC)[reply]

Cubic kilometres[edit]

Just noting that a cubic kilometre is 109 m3, and 1000 m3 would be the volume of a 10-metre cube. So km3 seems a bad abbreviation for a cubic kilometre. (km)3 would be technically correct I suppose, if ugly. A similar issue arises for square km and km2. I'll try to check recommended practice later. I've a nasty feeling that the "technically wrong" versions are accepted, but I still don't like ones which are out by a factor of a thousand or a million when taken literally. It's a matter of whether there's an explicit convention that distinguishes k(m3) from (km)3. Musiconeologist (talk) 14:28, 29 March 2024 (UTC)[reply]

According to International System of Units#Prefixes, the symbol cm3 means (cm)3, not c(m3).  Dr Greg  talk  15:18, 29 March 2024 (UTC)[reply]
@Dr Greg Thanks. I hadn't quite got that far—I was reading elsewhere about how to copy-edit units in various disciplines.
I've checked the International Bureau of Weights and Measures reference from that article now, and it reads:
The grouping formed by a prefix symbol attached to a unit symbol constitutes a new inseparable unit symbol (forming a multiple or sub-multiple of the unit concerned) that can be raised to a positive or negative power and that can be combined with other unit symbols to form compound unit symbols.
There's then an example which shows the steps in translating cm2 into m2 via (10-2m)2.
So it's unambiguous. Musiconeologist (talk) 18:32, 29 March 2024 (UTC)[reply]

Just...thank you[edit]

This template continues to rule. The fact that {{convert|95|liters/minute|USgal/minute|abbr=on|sp=us}} works and does everything I want it to, I'll swear, is the greatest thing ever. As a content creator, I am never not astounded by the array of parameters on this thing. It has never disappointed me yet. So to every coder who has ever laid a hand on this thing, THANK YOU. jengod (talk) 17:14, 13 April 2024 (UTC)[reply]

Well it still doesn't make my morning coffee, so to be honest I'm not all that impressed. EEng 21:19, 13 April 2024 (UTC)[reply]
Heh. (Obviously it would make coffee *and* tea if it we asked it nicely LOL) jengod (talk) 21:57, 13 April 2024 (UTC)[reply]
Just chuck in LD50 as a extra parameter and it'll tell you when you've really over-dosed! Martinevans123 (talk) 22:36, 13 April 2024 (UTC)[reply]
Convert does almost everything - but I'm still not sure how to convert caffeine g/minute into my 7:00am vodka pick-me-up for an equivalent LD50 ?  Stepho  talk  23:22, 13 April 2024 (UTC)[reply]
Hey EEng, can you add a coffee maker to the contraption above? Johnuniq (talk) 23:52, 13 April 2024 (UTC)[reply]
If it was in my power, you know I would. EEng 00:41, 14 April 2024 (UTC)[reply]

Template-protected edit request on 16 April 2024[edit]

the conversions are not quite correct Haydennnn (talk) 13:30, 16 April 2024 (UTC)[reply]

That's a big help. Thank you for bringing this to our attention. We'll get right on it. EEng 13:33, 16 April 2024 (UTC)[reply]
Yeah, but they're pretty good, aren't they. They'll probably do! At a pinch...? :) Martinevans123 (talk) 13:35, 16 April 2024 (UTC) Don't tell me, it's probably something about leptons and quarks, isn't it...[reply]
This request needs to be much more specific about what exactly is wrong to be implementable. * Pppery * it has begun... 14:35, 16 April 2024 (UTC)[reply]
Ya' think? EEng 14:36, 16 April 2024 (UTC)[reply]
It's probably gonna be about syntax ordering again, isn't it. Martinevans123 (talk) 14:40, 16 April 2024 (UTC)[reply]
Please see the first answer in the FAQ at the top of this page. Johnuniq (talk) 01:36, 17 April 2024 (UTC)[reply]
What this page needs is an edit filter that rejects any new section whose text doesn't begin with, "I have read the FAQs at the top of this page." EEng 02:10, 25 April 2024 (UTC)[reply]

abbr=unit and lk=on cause MOS:SEAOFBLUE issues[edit]

This example from Voyager 1:{{Convert|162.7|AU|e9km e9mi|sigfig=3|abbr=unit|lk=on}} renders as: 162.7 AU (24.3 billion km; 15.1 billion mi). This is pretty confusing, since the two links look like a link to billion km. I think billion should not be linked at all in this case. Nickps (talk) 22:27, 24 April 2024 (UTC)[reply]

Most readers will either understand what km and mi mean or don't care. It is only AU that would benefit from a link. I suggest changing |lk=on to |lk=in, so {{Convert|162.7|AU|e9km e9mi|sigfig=3|abbr=unit|lk=in}} gives 162.7 AU (24.3 billion km; 15.1 billion mi) .
Personally, I hate the abbreviation "mi" but that's another issue.  Stepho  talk  22:58, 24 April 2024 (UTC)[reply]
We can (and probably should) do what you suggest, but it won't change that the template behaves in an undesirable way when a certain combination of parameters is used. I still think this is something that should be fixed here. Nickps (talk) 23:42, 24 April 2024 (UTC)[reply]
I'll think about the linking problem another time although perfection may not be worth the effort, but I'm posting to say I also hate "mi" in cases like this. A long time ago I was pushing for unit code mile to be changed to show "mile" or "miles" even when abbreviated so people could have an easy and natural way to control the output. Write mi if "mi" is wanted for the symbol and mile or miles if "mile/miles" is wanted. If anyone wants to rekindle this, please start a new section. Johnuniq (talk) 02:00, 25 April 2024 (UTC)[reply]
I think the issue originally complained about is the link to billion. Being adjacent to km comes across as WP:SEAOFBLUE, but "billion" itself can be ambiguous due to linguistic history (either 109 or 1012 - would have been WP:ENGVAR a few years back). That's all explained in the linked article, so simply unlinking might not be the right answer. Tarl N. (discuss) 02:26, 25 April 2024 (UTC)[reply]
I had completely forgotten about the long scale. Since the billion article says about the long scale billion that it remained the most common sense of the word in Britain until the 1950s and still remains in occasional use there, we probably want to keep an explanation of the term. In that case, we could use {{tooltip}} instead as in billion, except that may not work on mobile and might seem superfluous to people who don't know the long scale. Nickps (talk) 16:13, 26 April 2024 (UTC)[reply]
Tooltip would probably be ideal, solving both SeaOfBlue and ambiguity. As for timeframe, it was only a few years ago that Nature magazine (UK publication) finally conceded the switchover to short scale, to some amount of anguish by readers. Tarl N. (discuss) 18:23, 26 April 2024 (UTC)[reply]