ctypes' c_longdouble: underflow error (bug?)

kj no.email at please.post
Wed Jul 14 09:24:31 EDT 2010




I have a C library function hg that returns a long double, so when
I import it using C types I specify this return type like this:

MYLIB.hg.restype = ctypes.c_longdouble

But certain non-zero values returned by hg appear as zero Python-side.
If I modify hg so that it prints out its value right before returning
it, I get stuff like the following:

>>> 0 == MYLIB.hg(100, 200, 100, 6000)
from hg: 2.96517e-161 
False
>>> 0 == MYLIB.hg(200, 200, 200, 6000)
from hg: 5.28791e-380
True

So, although the value returned by hg in the second invocation
above is 5.28791e-380, Python sees it as 0.

What am I doing wrong?

TIA!

~K



More information about the Python-list mailing list