Jerry Hill wrote: > I'm curious. Is there a way to get the number of significant digits > for a particular Decimal instance? I spent a few minutes browsing > through the docs, and didn't see anything obvious. I was thinking > about setting the precision dynamically within a function, based on > the significance of the inputs.
Not officially, so far as I know, but if you're willing to risk using a private implementation detail that is subject to change: >>> decimal.Decimal('000123.45000')._int '12345000' However, sometimes you may need to inspect the exponent as well: >>> zero = decimal.Decimal('0.00000000') >>> zero._int '0' >>> zero._exp -8 -- Steven -- http://mail.python.org/mailman/listinfo/python-list