Last modified: 2013-05-14 10:55:57 UTC
Necessary for - money (two decimal places) - exchange rates (four decimal places) etc.
Do you have a suggestion how this should be specified in the user input?
(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.
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.
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).