[Tutor] floating point accuracy [working with Fractions]

Kent Johnson kent37 at tds.net
Fri Nov 14 17:11:39 CET 2008

On Fri, Nov 14, 2008 at 3:39 AM, Karen Bester <Karen at smarttech.co.za> wrote:
> Hi
> Is there a method to determine the accuracy that you can get given a double
> precision number.  I'm looking for a formula or table that can tell me what
> accuracy I can get depending on "where" the decimal point lies.

I'm not really sure what you are looking for but you might be
interested in sys.float_info, available in Python 2.6. I think you may
want the mant_dig property:

There is no straightforward way to determine this in Python 2.5. If
you know the C compiler that was used to build Python, then you can
investigate its implementation of double.


More information about the Tutor mailing list