[Numpy-discussion] supporting quad precision

David Cournapeau cournape@gmail....
Wed Jun 12 18:00:41 CDT 2013


On Wed, Jun 12, 2013 at 7:55 PM, Anne Archibald <archibald@astron.nl> wrote:
> On 9 June 2013 13:23, David Cournapeau <cournape@gmail.com> wrote:
>>
>> So it depends on the CPU, the OS and the compiler. Using long double
>> for anything else than compatibility (e.g. binary files) is often a
>> mistake IMO, and highly unportable.
>
>
> Now this I have to comment on. Long double is highly questionable for
> compatibility, especially with binary files, for the reasons you describe.

By compatibiliy, I meant binary compatibility: if you have some binary
files or some API/ABI requiring long double, then using long double is
a requirement. Typical example, using structured dtypes to read some
binary headers with long double in it.

> But if what you want is something like double but with a few extra decimal
> places and hardware support, long double is exactly what you want. Portably!
> Some platforms will fail to give you any extra decimal places, and in-memory
> size may differ, but you can be pretty confident that it'll give you
> approximately what you're looking for anywhere.

Sure, if you want to have "at least double precision" behavior, it
gives you that. I fail to see how it could be useful in a portable
context if you actually require that extra precision: if it is ok to
fall back on double, why not using double in the first place ?

David


More information about the NumPy-Discussion mailing list