Significant figures calculation

Harold dadapapa at googlemail.com
Sun Jun 26 11:35:47 EDT 2011


> >I'm curious.  Is there a way to get the number of significant digits
> >for a particular Decimal instance?
>
> Yes:
>
> def sigdig(x):
>     "return the number of significant digits in x"
>     return len(x.as_tuple()[1])

Great! that's exactly what I needed.
thanks Chris!



More information about the Python-list mailing list