[Numpy-discussion] Preventing lossy cast for new float dtypes ?

David Cournapeau cournape@gmail....
Sat Aug 18 08:28:38 CDT 2012


Hi,

I have started toying with implementing a quad precision dtype for
numpy on supported platforms, using the __float128 + quadmath lib from
gcc. I have noticed invalid (and unexpected) downcast to long double
in some cases, especially for ufuncs (e.g. when I don't define my own
ufunc for a given operation).

Looking down in numpy ufunc machinery, I can see that the issue is
coming from the assumption that long double is the highest precision
possible for a float type, and the only way I can 'fix' this is to
define kind to a value != 'f' in my dtype definition (in which case I
get an expected invalid cast exception). Is there a way to still avoid
those casts while keeping the 'f' kind ?

thanks,

David


More information about the NumPy-Discussion mailing list