Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

decimal.Decimal formatting

2 views
Skip to first unread message

pyt...@lists.fastmail.net

unread,
Jul 19, 2010, 8:32:06 AM7/19/10
to pytho...@python.org
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.

Thijs

Stefan Krah

unread,
Jul 19, 2010, 11:23:39 AM7/19/10
to pytho...@python.org

Try:

>>> format(Decimal("0"), ".11f")
'0.00000000000'


Stefan Krah


0 new messages