Author: mail
Description:
Necessary for
- money (two decimal places)
- exchange rates (four decimal places)
etc.
Version: unspecified
Severity: enhancement
Author: mail
Description:
Necessary for
etc.
Version: unspecified
Severity: enhancement
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Declined | mkroetzsch | T22217 Precision of Type:Number cannot be specified on output | |||
Declined | Denny | T18571 Support parameters to control details of query printouts |
mail wrote:
(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 }}?
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.
mail wrote:
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
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.
bugzilla wrote:
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).
The Semantic MediaWiki developers requested in https://phabricator.wikimedia.org/T64114 to move their task tracking to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues and to close remaining tasks in Wikimedia Phabricator. If you still face the problem reported in this task in a supported version of SMW, please feel free to transfer your report to https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues . We are sorry for the inconvenience.