On 2007-03-02, Ulrich Dorda <[EMAIL PROTECTED]> wrote: > I need a pytho nscript to read numbers(with loads of digits) from a > file, do some basic math on it and write the result out to another file. > > My problem: I don't get python to use more digits: > > In order to try this I type: > > The normal precision one: > >>> from numpy import * > >>> x=1.23456789123456789123456789 > >>> print "%35.25e" %x > 1.2345678912345679000000000e+000 > > > Now I try to use float64 to get more digits
You're already using 64 bit floats (which have about 15 significant digits). > >>> z=zeros(3,float64) > >>> z[0] > 0.0 > >>> type(z[0]) ><type 'numpy.float64'> > >>> z[0]=1.23456789123456789123456789 > >>> type(z[0]) ><type 'numpy.float64'> > >>> print "%35.25e" %z[0] > 1.2345678912345679000000000e+000 > > This cuts the digits just like the 32bit case. What 32-bit case? A 32-bit float only has 7-8 significant digits. > Can anyone please help me get more digits? Use the decimal module? -- Grant Edwards grante Yow! What a at COINCIDENCE! I'm an visi.com authorized "SNOOTS OF THE STARS" dealer!! -- http://mail.python.org/mailman/listinfo/python-list