David Douard wrote:
> 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
> meaningfull).
> 
> But I may have missed something.

No, you didn't miss anything. I just haven't gotten enough sleep.

I thought that Python floats had a __str__ that computed just as many places as 
necessary, but it looks like it just rounds at 12 places. This is not an 
adjustable parameter (barring modifying the C code of the interpreter). I also 
thought that the float scalars were being printed differently. However, the 
code 
for the float64scalar __str__ just gets the double value, creates a Python 
float 
object from it, and returns the __str__ result from that object.

Everything works as intended. Nothing to see here. Move along.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to