[Numpy-discussion] float128 / longdouble on PPC - is it broken?
Tue Oct 25 13:29:06 CDT 2011
On Tue, Oct 25, 2011 at 11:14 AM, Pauli Virtanen <email@example.com> wrote:
> 25.10.2011 19:45, Matthew Brett kirjoitti:
>>> or, in case the platform doesn't have powl:
>>> long double x;
>>> x = pow(2, 64);
>>> x -= 1;
>>> printf("%g %Lg\n", (double)x, x);
>> Both the same as numpy:
>> [mb312@jerry ~]$ gcc test.c
>> test.c: In function 'main':
>> test.c:5: warning: incompatible implicit declaration of built-in function 'powl'
>> [mb312@jerry ~]$ ./a.out
>> 1.84467e+19 3.68935e+19
> This result may indicate that it's the *printing* of long doubles that's
> broken. Note how the value cast as double prints the correct result,
> whereas the %Lg format code gives something wrong.
Ah - sorry - I see now what you were trying to do.
> Can you try to check this by doing something like:
> - do some set of calculations using np.longdouble in Numpy
> (that requires the extra accuracy)
> - at the end, cast the result back to double
In : import numpy as np
In : res = np.longdouble(2)**64
In : res / 2**32
In : (res-1) / 2**32
In : np.float((res-1) / 2**32)
In : np.float((res) / 2**32)
More information about the NumPy-Discussion