[Numpy-discussion] [Numpy] quadruple precision
Matthew Brett
matthew.brett at gmail.com
Wed Feb 29 13:14:34 EST 2012
Hi,
On Wed, Feb 29, 2012 at 12:13 PM, Jonathan Rocher <jrocher at enthought.com> wrote:
> Thanks to your question, I discovered that there is a float128 dtype in
> numpy
>
> In[5]: np.__version__
> Out[5]: '1.6.1'
>
> In[6]: np.float128?
> Type: type
> Base Class: <type 'type'>
> String Form:<type 'numpy.float128'>
> Namespace: Interactive
> File:
> /Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/numpy/__init__.py
> Docstring:
> 128-bit floating-point number. Character code: 'g'. C long float
> compatible.
Right - but remember that numpy float128 is different on different
platforms. In particular, float128 is any C longdouble type that
needs 128 bits of memory, regardless of precision or implementation.
See [1] for background on C longdouble type.
The numpy platforms I know about are:
Intel : 80 bit float padded to 128 bits [2]
PPC : pair of float64 values [3]
Debian IBM s390 : real quadruple precision [4] [5]
I see that some Sun machines implement real quadruple precision in
software but I haven't run numpy on a Sun machine [6]
[1] http://en.wikipedia.org/wiki/Long_double
[2] http://en.wikipedia.org/wiki/Extended_precision#x86_Architecture_Extended_Precision_Format
[3] http://en.wikipedia.org/wiki/Double-double_%28arithmetic%29#Double-double_arithmetic
[4] http://en.wikipedia.org/wiki/Double-double_%28arithmetic%29#IEEE_754_quadruple-precision_binary_floating-point_format:_binary128
[5] https://github.com/nipy/nibabel/issues/76
[6] http://en.wikipedia.org/wiki/Double-double_%28arithmetic%29#Implementations
> Based on some reported issues, it seems like there are issues though with
> this and its mapping to python long integer...
> http://mail.scipy.org/pipermail/numpy-discussion/2011-October/058784.html
I tried to summarize the problems I knew about here:
http://mail.scipy.org/pipermail/numpy-discussion/2011-November/059087.html
There are some routines to deal with some of the problems here:
https://github.com/nipy/nibabel/blob/master/nibabel/casting.py
After spending some time with the various longdoubles in numpy, I have
learned to stare at my code for a long time considering how it might
run into the various problems above.
Best,
Matthew
More information about the NumPy-Discussion
mailing list