Template talk:Percentage: Difference between revisions
Guarapiranga (talk | contribs) →Significant figure: new section Tag: 2017 wikitext editor |
|||
Line 62: | Line 62: | ||
[[User:Sanglahi86|Sanglahi86]] ([[User talk:Sanglahi86|talk]]) 09:34, 10 October 2016 (UTC) |
[[User:Sanglahi86|Sanglahi86]] ([[User talk:Sanglahi86|talk]]) 09:34, 10 October 2016 (UTC) |
||
: [[User:Sanglahi86|Sanglahi86]], yes, it was not documented. now see the last example. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 15:17, 1 May 2017 (UTC) |
: [[User:Sanglahi86|Sanglahi86]], yes, it was not documented. now see the last example. [[User:Frietjes|Frietjes]] ([[User talk:Frietjes|talk]]) 15:17, 1 May 2017 (UTC) |
||
== Significant figure == |
|||
Is there an option to set significant figure precision (as in [[Template:sigfig]]) rather than number of decimal places? — [[User:Guarapiranga|Guarapiranga]] ([[User talk:Guarapiranga|talk]]) 08:31, 15 October 2019 (UTC) |
Revision as of 08:31, 15 October 2019
Move template
{{editprotected}}
Please move this template to Template:Percentage (which currently redirects here). It's common practice to spell out template names so that they are easy to read and understand what they are used for, and then have other names redirect to the template that are shorter to type. If you move this page, don't forget to move subpages. Gary King (talk · scripts) 01:17, 14 July 2010 (UTC)
- That makes sense.
Done — Martin (MSGJ · talk) 08:43, 14 July 2010 (UTC)
/core
I can't really see the purpose of having this subtemplate. In the edit summary you say "for use without percentage sign" but it would probably be easier to use a parameter to switch off the percentage sign rather than calling a separate template. I put some possible code in the /sandbox. — Martin (MSGJ · talk) 08:44, 14 July 2010 (UTC)
- I was thinking that /core could be used in other templates, especially those related to business where an increase from 100 to 200 would be a 100% increase, not a 200% increase as this template would report. Gary King (talk · scripts) 18:20, 14 July 2010 (UTC)
- Wouldn't be easier just to rewrite the code? Each level get us closer to the template limits (probably not a really huge concern but the code is so simple). We could use the code
{{#expr:100*{{{1|0}}}/{{{2|100}}} round ({{{3|0}}}>=0)*{{{3|0}}}}}{{{%|%}}}
and the % parameter would let us control how to write it{{percentage|80|300|%= percent}}
would give "27 percent",{{percentage|80|300|%=}}
would give "27" and{{percentage|80|300}}
, the default, would give "27%". JIMp talk·cont 18:17, 14 September 2011 (UTC)- ... Just thinking ... I joined this discussion over a year after the last comment. If the subpage were going to be used in the way Gary suggests, it should probably already be used like this now. Is it? Is the subpage being used directly from elsewhere? Let's find out. JIMp talk·cont 01:13, 15 September 2011 (UTC)
- Wouldn't be easier just to rewrite the code? Each level get us closer to the template limits (probably not a really huge concern but the code is so simple). We could use the code
Rounding to a negative precision
If we set parameter 3 to a negative, the template overrides this and uses zero instead. Why? JIMp talk·cont 18:19, 14 September 2011 (UTC)
- Why would you want to round to less than zero precision and what would that mean? --hydrox (talk) 04:58, 29 December 2013 (UTC)
- It probably means that e.g. {{Percentage | 1 | 3 | -1 }} yields 30%, i.e., a multiple of 10%. Gap9551 (talk) 13:50, 3 April 2017 (UTC)
Negative percentages... minus sign vs. ndash
The negative symbols between this template and {{PGR}} are different. I believe this simply uses the minus key on keyboards, whereas I believe the latter uses an ndash. Can we make the minus symbols consistent between the two templates? I believe this one should be made consistent with {{PGR}} and {{nts}}. See Alberta municipal censuses, 2013#Municipal census results where the inconsistency really sticks out. Hwy43 (talk) 22:53, 28 December 2013 (UTC)
- It seems to use the unicode minus sign, which at least on my PC is somewhere between mdash and ndash in width. I think it's pretty obvious this template too should use the unicode minus sign. I was able to get this effect by wrapping the whole numeric part of this template in {{nts}}. Hope this does not break anything.. --hydrox (talk) 04:55, 29 December 2013 (UTC)
- Thanks hydrox! Looks much better now. Cheers, Hwy43 (talk) 05:21, 29 December 2013 (UTC)
- @Hydrox: and that screwed up Template:Seven Sisters, but now fixed by using {{#expr:}} instead (see here), so probably not a big deal. Frietjes (talk) 01:23, 8 January 2014 (UTC)
- After the change, {{percentage}} now returns an HTML <span> element. That navbox was using the output as a CSS parameter, which was unanticipated. In case there are more uses of {{percentage}} in CSS expressions, or similar contexts where plain numeric value is desired, I have created {{percentage CSS}} as a drop-in replacement (i.e. changing {{percentage|...}} to {{percentage CSS|...}} should fix issues) --hydrox (talk) 06:43, 8 January 2014 (UTC)
- @Hydrox: not sure how to find all the problematic uses, if there are any left. Frietjes (talk) 15:46, 8 January 2014 (UTC)
- There's no way, but it's good to have that information available here anyway. --hydrox (talk) 15:57, 8 January 2014 (UTC)
- @Hydrox: not sure how to find all the problematic uses, if there are any left. Frietjes (talk) 15:46, 8 January 2014 (UTC)
- After the change, {{percentage}} now returns an HTML <span> element. That navbox was using the output as a CSS parameter, which was unanticipated. In case there are more uses of {{percentage}} in CSS expressions, or similar contexts where plain numeric value is desired, I have created {{percentage CSS}} as a drop-in replacement (i.e. changing {{percentage|...}} to {{percentage CSS|...}} should fix issues) --hydrox (talk) 06:43, 8 January 2014 (UTC)
- @Hydrox: and that screwed up Template:Seven Sisters, but now fixed by using {{#expr:}} instead (see here), so probably not a big deal. Frietjes (talk) 01:23, 8 January 2014 (UTC)
- Thanks hydrox! Looks much better now. Cheers, Hwy43 (talk) 05:21, 29 December 2013 (UTC)
formatnum:
Please use the parser function {{formatnum: NUMBER | R}}
in the template (example), otherwise cases such as {{percentage | {{NUMBEROFACTIVEUSERS}} | {{NUMBEROFUSERS}}}}
will not work. --Horcrux92 (talk) 08:57, 4 November 2015 (UTC)
Automatically display the numerator and percentage in separate table cells.
In a table, there should be a parameter to automatically display the numerator in one cell and the percentage in the other (just like what {{convert}}
template does using the disp=table
parameter). It should look like the table below (on which the template was manually placed in one cell and the numerator in another).
Municipality | Population | |
---|---|---|
Allen | 23,738 | 4% |
Las Navas | 36,539 | 6.2% |
— Preceding unsigned comment added by Sanglahi86 (talk • contribs) 05:41, 17 March 2016 (UTC)
- Thank you very much for creating that template (along with a very informative documentation). It is exactly what is needed for tables. Sanglahi86 (talk) 11:59, 13 April 2016 (UTC)
Word "percent"?
Hello. Is there an option to display the word percent
instead of the symbol %
? If yes, what is the format to use? Thanks.
Sanglahi86 (talk) 09:34, 10 October 2016 (UTC)
- Sanglahi86, yes, it was not documented. now see the last example. Frietjes (talk) 15:17, 1 May 2017 (UTC)
Significant figure
Is there an option to set significant figure precision (as in Template:sigfig) rather than number of decimal places? — Guarapiranga (talk) 08:31, 15 October 2019 (UTC)