Last modified: 2013-05-14 10:55:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T22217, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 20217 - Precision of Type:Number cannot be specified on output
Precision of Type:Number cannot be specified on output
Status: ASSIGNED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Markus Krötzsch
:
Depends on: 16571
Blocks:
  Show dependency treegraph
 
Reported: 2009-08-13 12:28 UTC by Patrick
Modified: 2013-05-14 10:55 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Patrick 2009-08-13 12:28:44 UTC
Necessary for
- money (two decimal places)
- exchange rates (four decimal places)
etc.
Comment 1 Markus Krötzsch 2009-08-14 08:23:50 UTC
Do you have a suggestion how this should be specified in the user input?
Comment 2 Patrick 2009-08-14 09:32:47 UTC
(In reply to comment #1)
> Do you have a suggestion how this should be specified in the user input?

How about

{{ #ask: somepage | ?Some_number_type_property#.2f }} for 2 digits after the decimal point? The output should be rounded. Just like 'printf' does it.

Or maybe

{{ #ask: somepage | ?Some_number_type_property#decplaces=2 }} or {{ #ask: somepage | ?Some_number_type_property#dp=2 }}?
Comment 3 Markus Krötzsch 2009-08-14 12:21:20 UTC
When using #, it would be necessary to combine this with units of measurement, which can be selected for some numerical types in a similar way. I suggest to wait for Denny to extend the ?printout syntax with additional parameters. Then one could use something like "decplaces=2" directly.
Comment 4 Patrick 2009-09-18 04:11:29 UTC
I created a tiny extension called Number_format that wraps PHP's number_format() function [1] as a temporary workaround. The source is available at [2]. It can be used in conjunction with 'format=template'.

Example: Lets say {{{1}}} (= 9823.2) is a monetary amount:

{{ #number_format: {{{1}}} | 2 }} -> 9,823.20
or, for example for German:
{{ #number_format: {{{1}}} | 2 | , | . }} -> 9.823,20

[1]: http://www.php.net/manual/en/function.number-format.php
[2]: http://patrick-nagel.net/misc/2009/Number_format.php.txt
Comment 5 [[kgh]] 2011-06-07 14:07:46 UTC
I am predominantly using the broadtable/ table format (for preview) and the csv format for dataexport. Thus a solution would be a cool for usability reasons.

Currently SWM drops the entries for decimal places if they are a 0, e.g. 5,50 → 5,5 or 5,00 → 5. This should be fixed somehow too.
Comment 6 Stefahn 2013-05-14 10:55:57 UTC
Any update on this?
I think it would be a really helpful if one could specify the precision of a number (I am trying to show currencies with two decimal places).

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links