Difference between revisions of "Template:INRConvert/Wordify"

From blackwiki
Jump to navigation Jump to search
imported>Joshua Issac
(Reverted to revision 925548882 by Joshua Issac (talk): Last working version (TW))
imported>Joshua Issac
(added formatnum for amounts smaller than a million (usa) or a lakh (ind) and larger than trillion (usa) or lakh crore (ind).)
 
Line 2: Line 2:
  
 
This template will factorise out trillion, billion and million from the given number for the short scale system. Use the <code>round</code> parameter to round the resulting number (e.g. <code>round=3</code> will yield 1.010 billion). Use the <code>numsys</code> parameter to choose the numbering system; currently, the supported arguments are <code>usa</code> for the [[short scale]] and <code>ind</code> for the [[Indian numbering system]].
 
This template will factorise out trillion, billion and million from the given number for the short scale system. Use the <code>round</code> parameter to round the resulting number (e.g. <code>round=3</code> will yield 1.010 billion). Use the <code>numsys</code> parameter to choose the numbering system; currently, the supported arguments are <code>usa</code> for the [[short scale]] and <code>ind</code> for the [[Indian numbering system]].
 +
The number output will be formatted to add decimal separators in the case of large numbers.
  
 
[[Category:Numbers as words conversion templates]]
 
[[Category:Numbers as words conversion templates]]
Line 7: Line 8:
 
</noinclude>{{#switch: {{{numsys|usa}}}
 
</noinclude>{{#switch: {{{numsys|usa}}}
 
| usa = {{#ifexpr: {{{1|1}}}/1E12 >= 1
 
| usa = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} trillion
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} trillion
 
| {{#ifexpr: {{{1|1}}}/1E9 >= 1
 
| {{#ifexpr: {{{1|1}}}/1E9 >= 1
 
| {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} billion
 
| {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} billion
 
| {{#ifexpr: {{{1|1}}}/1E6 >= 1
 
| {{#ifexpr: {{{1|1}}}/1E6 >= 1
 
| {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million
 
| {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million
| {{#expr: {{{1|1}}} round {{{round|2}}}}}
+
| {{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}
 
}}
 
}}
 
}}
 
}}
 
}}
 
}}
 
| ind = {{#ifexpr: {{{1|1}}}/1E12 >= 1
 
| ind = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} lakh crore
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} lakh crore
 
| {{#ifexpr: {{{1|1}}}/1E7 >= 1
 
| {{#ifexpr: {{{1|1}}}/1E7 >= 1
 
| {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} crore
 
| {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} crore
 
| {{#ifexpr: {{{1|1}}}/1E5 >= 1
 
| {{#ifexpr: {{{1|1}}}/1E5 >= 1
 
| {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} lakh
 
| {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} lakh
| {{#expr: {{{1|1}}} round {{{round|2}}}}}
+
| {{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}
 
}}
 
}}
 
}}
 
}}
 
}}
 
}}
 
| #default = number system not supported}}
 
| #default = number system not supported}}

Latest revision as of 16:24, 16 August 2020

This subtemplate will accept a number and output a formatted string with a smaller number and the divisor as a word in a number scaling system. For example, an input of 1010000 (with the short scale system and rounding to two decimal places) will result in an output of "1.01 billion".

This template will factorise out trillion, billion and million from the given number for the short scale system. Use the round parameter to round the resulting number (e.g. round=3 will yield 1.010 billion). Use the numsys parameter to choose the numbering system; currently, the supported arguments are usa for the short scale and ind for the Indian numbering system. The number output will be formatted to add decimal separators in the case of large numbers.

1