What precision does numpy.float128 map to internally? Is it __float128 or long double? Or something else entirely?
A potential follow on question if anybody knows: is it safe in C to cast a __float128 to a (16 byte) long double, with just a loss in precision? (this is for interfacing with a C lib that operates on long doubles).
Edit: In response to the comment, the platform is ‘Linux-3.0.0-14-generic-x86_64-with-Ubuntu-11.10-oneiric’. Now, if numpy.float128 has varying precision dependent on the platform, that is also useful knowledge for me!
Just to be clear, it is the precision I am interested in, not the size of an element.
It’s quite recommended to use
longdoubleinstead of float128, since it’s quite a mess, ATM. Python will cast it tofloat64during initialization.Inside numpy, it can be a double or a long double. It’s defined in
npy_common.hand depends of your platform. I don’t know if you can include it out-of-the-box into your source code.If you don’t need performance in this part of your algorithm, a safer way could be to export it to a string and use
stroldafterwards.