Significant figures calculation
Lalitha Prasad K
lalitha.prasad at faithinfotech.in
Sun Jun 26 23:49:13 EDT 2011
In numerical analysis there is this concept of machine zero, which is
computed like this:
e=1.0
while 1.0+e > 1.0:
e=e/2.0
print e
The number e will give you the precision of floating point numbers.
Lalitha Prasad
On Sun, Jun 26, 2011 at 9:05 PM, Harold <dadapapa at googlemail.com> wrote:
> > >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!
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110627/cb1abf0b/attachment-0001.html>
More information about the Python-list
mailing list