Significant figures calculation

Dave Angel davea at ieee.org
Mon Jun 27 08:04:10 EDT 2011


(You top-posted your reply, instead of writing your response following 
the part you were quoting)

On 01/-10/-28163 02:59 PM, Lalitha Prasad K wrote:
> 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
>

That particular algorithm is designed for binary floating point. The OP 
was asking about Decimal instances.  So you'd want to divide by 10.0 
each time.  And of course you'd want to do it with Decimal objects.
> 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?

DaveA




More information about the Python-list mailing list