Page MenuHomePhabricator

Decimal point is lost in formatnum for large numbers
Closed, InvalidPublic

Description

Using the sequence {{formatnum:{{#property:P1181}}}} gives a big number, which often should be rendered with a decimal point. That often fails, and the decimal point is lost.

See for example w:no:Pi. In this case there should be a decimal comma.

This is partly Wikibase allowing large numbers, and partly ParserFunctions failing to handle such large numbers. I believe this failure is mostly on assumptions in ParserFunctions.

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Danmichaelo, Aklapper. · View Herald Transcript
Dinoguy1000 renamed this task from Decimal point is lost in fomatnum for large numbers to Decimal point is lost in formatnum for large numbers.Sep 13 2019, 11:56 PM
Nikerabbit subscribed.

Using this input on Special:ExpandTemplates with Pi as page name:

{{#property:P1181}}
{{#statements:P1181}}
{{formatnum:{{#property:P1181}}}}

I get:

3,1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938
<span><span>3,1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938</span></span>
3 1 415 926 535 897 932 384 626 433 832 795 028 841 971 693 993 751 058 209 749 445 923 078 164 062 862 089 986 280 348 253 421 170 679 821 480 865 132 823 066 470 938

This is clearly the case of invalid input to FORMATNUM, it only accepts unformatted numbers with decimal period. You shouldn't format already formatted numbers. You might want to file a ticket asking for ability to return unformatted numbers from Wikibase.

Yes, my bad. I did not notice it was a comma, and assumed it was an unformatted number.