From: David D. <dav...@lo...> - 2006-07-10 14:07:32
|
On Mon, Jul 10, 2006 at 08:46:33AM -0500, Robert Kern wrote: > Tim Hochberg wrote: > > Nils Wagner wrote: > >> Hi all, > >> > >> how can I increase the number of digits in the output of str(.) ? > >> =20 > > You can't as far as I know. For floats, you can use "%.nf". For example: > >=20 > > "%.13f" % 493.4802200544680 >=20 > The problem is is that he doesn't have a float. He has one of our float64= scalar=20 > objects. The str() of a real Python float will give as many digits as are= =20 > necessary to recreate number and no more (or maybe one or two more). A st= r() of=20 > a float64scalar will round according to some rule that I haven't figured = out,=20 > yet. It doesn't seem to be configurable with numpy.set_printoptions(). This is a different ptoblem from the one exposed by Nils. I mean, tha fact that str() on numpy.float64 objects is somewhat obscure is a problem that should obviously be addressed some day. However, as far as I understand Nils' message, the "%.13f" trick is enough for what he need. But I may be wrong... He just want to "increase the number of digits", not have the "optimal" number of digits (as long as this is meaningfull). But I may have missed something. David --=20 David Douard LOGILAB, Paris (France) Formations Python, Zope, Plone, Debian : http://www.logilab.fr/formations D=E9veloppement logiciel sur mesure : http://www.logilab.fr/services Informatique scientifique : http://www.logilab.fr/science |