Page MenuHomePhabricator

Precision of Type:Number cannot be specified on output
Closed, DeclinedPublic

Description

Author: mail

Description:
Necessary for

  • money (two decimal places)
  • exchange rates (four decimal places)

etc.


Version: unspecified
Severity: enhancement

Details

Reference
bz20217

Event Timeline

bzimport raised the priority of this task from to Normal.Nov 21 2014, 10:47 PM
bzimport set Reference to bz20217.

Do you have a suggestion how this should be specified in the user input?

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

Kghbln added a comment.Jun 7 2011, 2:07 PM

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).

Aklapper closed this task as Declined.Mar 3 2015, 5:50 PM
Aklapper added a subscriber: Aklapper.

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.