array precision

Barry Drake bldrake1 at yahoo.com
Thu Feb 7 08:36:38 EST 2002


Michael,
Sorry you missed my point.  Try "Intro to Matrix Computations" by
Stewart, first few chapters for the numerical portion.  As for the
double versus float, that is what I read in Beasley's book, which I
mentioned.  I'm new to Python and obviously don't have the vast
experience you have.  But, I'll keep trying.

Regards,
Barry Drake

Michael Hudson <mwh at python.net> wrote in message news:<ug04da4k1.fsf at python.net>...
> bldrake1 at yahoo.com (Barry Drake) writes:
> 
> > Maybe I'm missing something, but here is what I get:
> 
> Well, I'm missing your point.
> 
> > Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on
> > win32
> > Type "copyright", "credits" or "license" for more information.
> > IDLE 0.8 -- press F1 for help
> > >>> import math
> > >>> n = 10
> > >>> nf = 10.0
> > >>> a = 1.0
> > >>> b = 0.5
> > >>> a/n
>  0.10000000000000001
> > >>> b + a/n
>  0.59999999999999998
> > >>> a/nf
>  0.10000000000000001
> > >>> b + a/nf
>  0.59999999999999998
> > >>> 
> > 
> > Python does double precision floats only (see Python Essential
> > Reference 2nd ed. by David Beazley, p.23).
> 
> But you can have arrays (as in, objects of type array.ArrayType) that
> store C single floats.  Which was Jason's point.
> 
> > Python implements IEEE 754: 17 digits of precision with exponent in
> > -308 to 308.
> 
> Oh No It Doesn't.  Python uses (for the objects of type
> types.FloatType) whatever the C compiler that compiled it called
> "double".  This may be IEEE 754 doubles on the platforms you've used,
> but there's certainly no guarantee of that (e.g. Crays, IBM boxes (I
> think)).
> 
> >          float     double
> > python   64 bits   64 bits
> > C        32 bits   64 bits
> 
> "python double" is meaningless.
> 
> > BTW, you might want to check out the Numeric module in the NumPy
> > distribution at http://numpy.sourceforge.net.
> 
> That lets you store floats or doubles too.
> 
> Cheers,
> M.



More information about the Python-list mailing list