Difference between revisions of "Template:FXConvert/Wordify"

From blackwiki
Jump to navigation Jump to search
imported>Trigenibinion
(Linking disabled by default)
imported>Trigenibinion
(Reduce expansion depth)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>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".
+
<includeonly>{{#if:{{Isnumeric|{{{1|}}}}}|
 
+
{{#switch: {{{numsys|usa}}}
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]]
 
 
 
</noinclude>{{#switch: {{{numsys|usa}}}
 
 
| usa = {{#ifexpr: {{{1|1}}}/1E12 >= 1
 
| usa = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} {{#ifeq:{{{lk|}}}|on|[[1,000,000,000,000|trillion]]|trillion}}
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} {{#ifeq:{{{lk|}}}|on|[[1,000,000,000,000|trillion]]|trillion}}}}
| {{#ifexpr: {{{1|1}}}/1E9 >= 1
+
  {{#ifexpr: {{{1|1}}}/1E12 < 1 and {{{1|1}}}/1E9 >= 1
| {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[1,000,000,000|billion]]|billion}}
+
| {{#expr: {{{1|1}}}/1E9 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[1,000,000,000|billion]]|billion}}}}
| {{#ifexpr: {{{1|1}}}/1E6 >= 1
+
  {{#ifexpr: {{{1|1}}}/1E9 < 1 and {{{1|1}}}/1E6 >= 1
| {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million
+
| {{#expr: {{{1|1}}}/1E6 round {{{round|2}}}}} million}}
| {{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}
+
  {{#ifexpr: {{{1|1}}}/1E6 < 1|{{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}}}
}}
 
}}
 
}}
 
 
| ind = {{#ifexpr: {{{1|1}}}/1E12 >= 1
 
| ind = {{#ifexpr: {{{1|1}}}/1E12 >= 1
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} {{#ifeq:{{{lk|}}}|on|[[lakh]] [[crore]]|lakh crore}}
+
| {{formatnum:{{#expr: {{{1|1}}}/1E12 round {{{round|2}}}}}}} {{#ifeq:{{{lk|}}}|on|[[lakh]] [[crore]]|lakh crore}}}}
| {{#ifexpr: {{{1|1}}}/1E7 >= 1
+
  {{#ifexpr: {{{1|1}}}/1E12 < 1 and {{{1|1}}}/1E7 >= 1
| {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[crore]]|crore}}
+
| {{#expr: {{{1|1}}}/1E7 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[crore]]|crore}}}}
| {{#ifexpr: {{{1|1}}}/1E5 >= 1
+
  {{#ifexpr: {{{1|1}}}/1E7 < 1 and {{{1|1}}}/1E5 >= 1
| {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[lakh]]|lakh}}
+
| {{#expr: {{{1|1}}}/1E5 round {{{round|2}}}}} {{#ifeq:{{{lk|}}}|on|[[lakh]]|lakh}}}}
| {{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}
+
  {{#ifexpr: {{{1|1}}}/1E5 < 1|{{formatnum:{{#expr: {{{1|1}}} round {{{round|2}}}}}}}}}
}}
+
| #default = number system not supported}}|{{Error|[[Template:FXConvert/Wordify|FXConvert/Wordify]] error: cannot parse value "{{{1|}}}"}}}}</includeonly><noinclude>{{Documentation}}</noinclude>
}}
 
}}
 
| #default = number system not supported}}
 

Latest revision as of 22:31, 16 January 2021

50px Template documentation[create]