Template:Val/delimitnum: Difference between revisions
From Zoophilia Wiki
Jump to navigationJump to search
meta>Jimp handling of ".1" etc. |
meta>Cpiral 4-digit pure, and no fmt=commas4, and no concern with units |
||
Line 1: | Line 1: | ||
<includeonly>{{# | <includeonly>{{#ifeq: | ||
{{#invoke:String|find|{{{1}}}|[+-.]|plain=false}}{{#invoke:String|len|{{{1}}}}}{{{fmt|}}} | |||
| 4 |{{{1}}}<!-- if fmt is nil,found +=. is 0, len is 4, | |||
then 04=4, output the number, else: | |||
-->|{{#switch: <!-- its not a pure 4-digit number with no fmt options given--> | |||
{{#invoke:String|sub|{{{1|0}}}|1|1}} | |||
<!-- If the first char is ... --> | |||
|- <!-- ... one kind of dash, or another --> | |||
|− = {{#ifeq:{{{nosign|off}}}|off|−}}<!-- output a − sign unless nosign | |||
-->{{#ifeq: | |||
{{#invoke:String|sub|{{{1|0}}}|2|2}}|.|0}}<!--And then | |||
}} | then if next char is . then output a zero, else do || nothing. | ||
|+={{#ifeq:{{{nosign|off}}}|off | -->{{#switch: {{{fmt}}} <!-- Format the rest of the number. --> | ||
|commas={{formatnum:{{#invoke:String|sub|{{{1|0}}}|2}}}} | |||
|#default = {{#invoke:Gapnum|main|{{#invoke:String|sub|{{{1|0}}}|2}}}} | |||
}} | |||
<!-- follow same logic for leading + char --> | |||
|+={{#ifeq:{{{nosign|off}}}|off|+}}<!-- | |||
-->{{#ifeq:{{#invoke:String|sub|{{{1|0}}}|2|2}}|.|0}}<!-- | |||
-->{{#switch:{{{fmt}}} | |||
|commas = {{formatnum:{{#invoke:String|sub|{{{1|0}}}|2}}}} | |||
|#default = {{#invoke:Gapnum|main|{{#invoke:String|sub|{{{1|0}}}|2}}}} | |||
}} <!-- follow similar logic for leading . char --> | |||
|.=0{{#switch:{{{fmt}}} | |.=0<!-- | ||
-->{{#switch:{{{fmt}}} | |||
|commas={{{1|0}}} | |||
|#default = {{#invoke:Gapnum|main|{{{1|0}}}}} | |||
}} | |||
|{{#switch:{{{fmt} | |||
<!-- Else if first char is not . or - or + --> | |||
|#default = {{#switch:{{{fmt}}} | |||
|commas={{formatnum:{{{1|0}}}}} | |||
|#default = {{#invoke:Gapnum|main|{{{1|0}}}}} | |||
|commas= | |||
| | |||
}} | }} | ||
}} | }} | ||
}}</includeonly><noinclude>{{documentation}}</noinclude> | }}</includeonly><noinclude>{{documentation}}</noinclude> |