Difference between revisions of "Template:INRConvert/Wordify"

From blackwiki
Jump to navigation Jump to search
imported>Joshua Issac
m (test: removing default)
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).)
 
(2 intermediate revisions by the same user not shown)
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.
[[Template:INRConvert/inflation/b]] does something similar to this template.
 
  
 
[[Category:Numbers as words conversion templates]]
 
[[Category:Numbers as words conversion templates]]
  
 
</noinclude>{{#switch: {{{numsys|usa}}}
 
</noinclude>{{#switch: {{{numsys|usa}}}
| usa = {{#switch: {{Order of magnitude|{{{1}}}}}
+
| usa = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| 12 = {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} trillion
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} trillion
| 9 = {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} billion
+
| {{#ifexpr: {{{1|1}}}/1E9 >= 1
| 6 = {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million
+
| {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} billion
| #default = {{#ifexpr: {{{1|1}}}/1E12 >= 1
+
| {{#ifexpr: {{{1|1}}}/1E6 >= 1
| {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} trillion<!-- greater than a trillion -->
+
| {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million
| {{#expr: {{{1|1}}} round {{{round|2}}}}}<!-- less than a million -->
+
| {{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}
 +
}}
 
}}
 
}}
 
}}
 
}}
| ind = {{#switch: {{Order of magnitude|{{{1|1}}}}}
+
| ind = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| 12 = {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} lakh crore
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} lakh crore
| 7 = {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} crore
+
| {{#ifexpr: {{{1|1}}}/1E7 >= 1
| 5 = {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} lakh
+
| {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} crore
| #default = {{#ifexpr: {{{1|1}}}/1E12 >= 1
+
| {{#ifexpr: {{{1|1}}}/1E5 >= 1
| {{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}} lakh crore<!-- greater than a lakh crore -->
+
| {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} lakh
| {{#expr: {{{1|1}}} round {{{round|2}}}}}<!-- less than a lakh -->
+
| {{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