i have a c function which returns a long double
. i'd like to call this function from python using ctypes, and it mostly works. setting so.func.restype = c_longdouble
does the trick -- except that python's float type is a c_double
so if the returned value is larger than a double, but well within the bounds of a long double, python still gets inf as the return value. i'm on a 64 bit processor and sizeof(long double)
is 16.
any ideas on getting around this (e.g. using the decimal class or numpy) without modifying the c code?