Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-02 Thread Chris Barker
Pauli Virtanen wrote: > We'll just need to add long double versions of NumPyOS_ascii_strtod and > NumPyOS_ftolf that call sscanf with the correct format string in the end. hmm -- if you're going to do that, maybe we could re-factor and use sscanf everywhere instead of ato*() -- the ato* function

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-02 Thread Pauli Virtanen
Thu, 02 Sep 2010 18:13:23 +0100, Colin Macdonald wrote: > On 09/02/10 17:06, Christopher Barker wrote: >> Does the clib for a compiler that provides a float64 also provide an >> atof() function that supports it? Its seems that it should. > > I think so, for example in C I can do: > > fscanf(fp, "

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-02 Thread Colin Macdonald
On 09/02/10 17:06, Christopher Barker wrote: > Does the clib for a compiler that provides a float64 also provide an > atof() function that supports it? Its seems that it should. I think so, for example in C I can do: fscanf(fp, "%Lf %Lf %Lf", &x, &y, &z); where x,y,z are "long doubles". The equ

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-02 Thread Christopher Barker
Charles R Harris wrote: >>> So if you write "float96(0.0001)", the result is not the float96 number >>> closest to 0.0001, but the 96-bit representation of the 64-bit number >>> closest to 0.0001. ... >> but wouldn't it be better to exactly handle strings since those can be >> converted exactly, w

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread David Cournapeau
On Thu, Sep 2, 2010 at 10:03 AM, Charles R Harris wrote: > > > On Wed, Sep 1, 2010 at 3:30 PM, Michael Gilbert > wrote: >> >> On Wed, 1 Sep 2010 21:15:22 + (UTC), Pauli Virtanen wrote: >> > Wed, 01 Sep 2010 16:26:59 -0400, Michael Gilbert wrote: >> > > I've been using numpy's float96 class la

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Charles R Harris
On Wed, Sep 1, 2010 at 3:30 PM, Michael Gilbert wrote: > On Wed, 1 Sep 2010 21:15:22 + (UTC), Pauli Virtanen wrote: > > Wed, 01 Sep 2010 16:26:59 -0400, Michael Gilbert wrote: > > > I've been using numpy's float96 class lately, and I've run into some > > > strange precision errors. > > [clip]

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Colin Macdonald
On 09/01/10 22:30, Michael Gilbert wrote: > Interesting. float96( '0.0001' ) also seems to evaluate to the first > result. I assume that it also does a float64( '0.0001' ) conversion > first. I understand that you can't change how python passes in floats, > but wouldn't it be better to exactly han

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Michael Gilbert
On Wed, 1 Sep 2010 21:15:22 + (UTC), Pauli Virtanen wrote: > Wed, 01 Sep 2010 16:26:59 -0400, Michael Gilbert wrote: > > I've been using numpy's float96 class lately, and I've run into some > > strange precision errors. > [clip] > > >>> x = numpy.array( [0.01] , numpy.float96 ) > [clip] > > I

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Pauli Virtanen
Wed, 01 Sep 2010 16:26:59 -0400, Michael Gilbert wrote: > I've been using numpy's float96 class lately, and I've run into some > strange precision errors. [clip] > >>> x = numpy.array( [0.01] , numpy.float96 ) [clip] > I would expect the float96 calculation to also produce 0.0 exactly as > found

Re: [Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Charles R Harris
On Wed, Sep 1, 2010 at 2:26 PM, Michael Gilbert wrote: > Hi, > > I've been using numpy's float96 class lately, and I've run into some > strange precision errors. See example below: > > >>> import numpy > >>> numpy.version.version > '1.5.0' > >>> sys.version > '3.1.2 (release31-maint, Jul 8

[Numpy-discussion] Unexpected float96 precision loss

2010-09-01 Thread Michael Gilbert
Hi, I've been using numpy's float96 class lately, and I've run into some strange precision errors. See example below: >>> import numpy >>> numpy.version.version '1.5.0' >>> sys.version '3.1.2 (release31-maint, Jul 8 2010, 01:16:48) \n[GCC 4.4.4]' >>> x = numpy.array( [0.01] , numpy.