need the unsigned value from dl.call()
Larry Bates
larry.bates at websafe.com
Tue Dec 11 10:11:05 EST 2007
eliss wrote:
> I'm using dl.call() to call a C function in an external library. It's
> working great so far except for one function, which returns an
> unsigned int in the C version. However, in python it returns a signed
> value to me. How can I get the unsigned value from this? I haven't
> brushed up on my two's complement in a while, so I was hoping someone
> could give me a hand.
>
> Thanks
>
> eliss
It is returning 32 bits. If the sign bit (bit 32) is on it appears as a
negative number. Test for negative and multiply the absolute value * 2.
That should get you the unsigned value you want in a long.
-Larry
More information about the Python-list
mailing list