[Numpy-discussion] Number of digits

David Douard david.douard at logilab.fr
Mon Jul 10 09:08:23 CDT 2006

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(.) ?
> >>   
> > You can't as far as I know. For floats, you can use "%.nf". For example:
> > 
> > "%.13f" % 493.4802200544680
> The problem is is that he doesn't have a float. He has one of our float64scalar 
> objects. The str() of a real Python float will give as many digits as are 
> necessary to recreate number and no more (or maybe one or two more). A str() of 
> a float64scalar will round according to some rule that I haven't figured out, 
> 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

But I may have missed something.


David Douard                             LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian : http://www.logilab.fr/formations
Développement logiciel sur mesure :      http://www.logilab.fr/services
Informatique scientifique :              http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060710/712b3f14/attachment.bin 

More information about the Numpy-discussion mailing list