decimal.Decimal formatting
Stefan Krah
stefan-usenet at bytereef.org
Mon Jul 19 11:23:39 EDT 2010
python at lists.fastmail.net <python at lists.fastmail.net> wrote:
> I have various decimals which eventually are written to an XML file.
> Requirements indicate a precision of 11. I am currently having some
> 'issues' with Decimal("0"). When using
> quantize(decimal.Decimal("1e-11")) the result is not 0.00000000000, but
> 1e-11.
>
> Personally I agree 1e-11 is a better notation than 0.00000000000, but I
> currently need the long one. Is there a way to overwrite the switch to
> the scientific notation? Apparently there is a switch in notation
> 'between' 1e-6 and 1e-7.
Try:
>>> format(Decimal("0"), ".11f")
'0.00000000000'
Stefan Krah
More information about the Python-list
mailing list