Last modified: 2009-01-13 11:25:50 UTC
According to the wiki's default locale settings in de.wikipedia.org the magic word "formatnum" leads to replacing "." by ",", e.g. {{formatnum:1.2}} results in "1,2". If a template with some parameters is called and the result of this template should be formatted via "formatnum" a parser error occurs. This happends because the parameters contain "," and the parser expects to receive ".". example: {{formatnum: {{sum|1.2|3.4}} }} 1. step of incorrect evalutation: {{sum|1,2|3,4}} 2. step of incorrect evaluation: (parser error in Template:Sum) {{#expr: 1,2 + 3,4}} workaround: {{formatnum: {{#expr: 1,2 + 3,4}} }}
correction of workaround: {{formatnum: {{#expr: 1.2 + 3.4}} }}
I'm afraid there's not much to do about this other than ensure that you're using proper formatting for your math. The system shouldn't try to guess whether input is locale-formatted or not, since there are many many ambiguous cases... does "5.000" mean five thousand or five to three decimal places? There's no way to know in isolation.
Hi Brion, you missunderstood the description of the problem. The problem is the order of evaluation. The parser should evaluate "formatnum(sum(1.2, 3.4))" if I'm writing {{formatnum: {{sum|1.2|3.4}} }}. But actually the expression is evaluated in follwing order: "sum(formatnum(1.2), formatnum(3.4))" which leads to the expression "sum(1,3, 3,4)" and ends in a parser error. Of course the parser shouldn't "guess" the format of the parameters. But it should evaluate the expressions in the correct order.
Can you provide the text of this Template:Sum used in your examples? It doesn't seem to be present on de.wikipedia.org.
The Template:Sum is a fictive example and would have been coded like this: {{#expr: {{{1|0}}} + {{{2|0}}} }} The described problem actually occured in the template "Vorlage:Klimatabelle" and its sub-template "Vorlage:Klimatabelle/Durchschnitt" which calculates the average of twelve values. The workaround can be found here: http://de.wikipedia.org/w/index.php?title=Vorlage%3AKlimatabelle&diff=40952394&oldid=40951597
I'm still unable to reproduce any problem with the examples. Vorlage:Sum: {{#expr: {{{1|0}}} + {{{2|0}}} }} Vorlage:Sumwrapper: {{formatnum: {{sum|{{{1}}}|{{{2}}}}} }} Invocation: {{sumwrapper|1.2|3.4}} Tested both with old and new parser.
The problem occurs with this code: Vorlage:Klimatabelle: {{formatnum: {{Klimatabelle/Durchschnitt{{!}} {{{hmjan|0}}} {{!}} {{{hmfeb|0}}} {{!}} {{{hmmär|0}}} {{!}} {{{hmapr|0}}} {{!}} {{{hmmai|0}}} {{!}} {{{hmjun|0}}} {{!}} {{{hmjul|0}}} {{!}} {{{hmaug|0}}} {{!}} {{{hmsep|0}}} {{!}} {{{hmokt|0}}} {{!}} {{{hmnov|0}}} {{!}} {{{hmdez|0}}} }} }} While Vorlage:Klimatabelle/Durchschnitt contains following code: {{#expr: ({{{1|0}}} + {{{2|0}}} + {{{3|0}}} + {{{4|0}}} + {{{5|0}}} + {{{6|0}}} + {{{7|0}}} + {{{8|0}}} + {{{9|0}}} + {{{10|0}}} + {{{11|0}}} + {{{12|0}}}) / 12 round 1 }} The parser error doesn't occur if I change the code of Vorlage:Klimatabelle to: {{formatnum: {{#expr: ({{{hmjan|0}}} + {{{hmfeb|0}}} + {{{hmmär|0}}} + {{{hmapr|0}}} + {{{hmmai|0}}} + {{{hmjun|0}}} + {{{hmjul|0}}} + {{{hmaug|0}}} + {{{hmsep|0}}} + {{{hmokt|0}}} + {{{hmnov|0}}} + {{{hmdez|0}}}) / 12 round 1 }} }}
Ok, sample usage: {{Klimatabelle|hmjan=11|hmfeb=12|hmmär=13|hmapr=14|hmmai=15|hmjun=16|hmjul=17|hmaug=18|hmsep=19|hmokt=20|hmnov=21|hmdez=22}} I still can't reproduce any problem with the formatting, either with old or new parser, except this: With the new parser (not yet live), your {{!}} usages are incorrect and the entire template fails. Use | only here. I get 16.5 in English or 16,5 set to German.
Accidentally marked as WORKSFORME.
But it *does* WORKFORME... :-D