[Zope-dev] Decimal formatter truncating to 3 decimal places - why?

Markus Kemmerling markus.kemmerling at meduniwien.ac.at
Thu May 7 09:48:45 EDT 2009


Am 07.05.2009 um 15:10 schrieb Hermann Himmelbauer:

> Hi,
> In my code, I use the decimal.Decimal datatype, which I try to  
> format like
> this:
>
> formatter = self.request.locale.numbers.getFormatter('decimal')
> formatted_value = formatter.format(value)
>
> The problem is, that the decimal number is truncated (rounded) to 3  
> decimal
> places, e.g. 1.123456 -> 1.123.
>
> Is there a way to stop this?

You may pass the format method a pattern as keyword arg, e.g.:

formatted_value = formatter.format(value, '0.0#####')

but I don't think you can tell the formatter to not round the fraction  
at all.

Regards,
Markus Kemmerling


More information about the Zope-Dev mailing list