While numpy supports more decimal types (as well as complex versions), they do not help:
>>> import numpy >>> numpy.longfloat <type 'numpy.float128'> >>> a = numpy.array([200, 2e-26], dtype=numpy.longfloat) >>> a array([ 200.0, 2e-26], dtype=float128) >>> a.sum() 200.0 >>> a = numpy.array([200, 2e-26], dtype=numpy.longdouble) >>> a.sum() 200.0
The reason is explained here : 80 bits are used inside numpy , which means 63 bits of the mantissa, which only supports 63/3 = 21 characters.
You need a real 128-bit float type as one of boost .
Try the Boost.Python module , which can give you access to this type. If this does not work, you will have to write your own wrapper class in C ++, as described here .
Aaron digulla
source share