From: dumonts <du...@fi...> - 2002-06-03 15:00:54
|
I use the following function to convert a 'long' python equivalent into an 'unsigned long long' C eqivalent. Without using jython, this function works. I don't know how i can do it, in another way, to apply jythonc interpreter on this function. import struct def pack (n) : # 0 <= n <= 2 ** 64 - 1 # Convert a 'long' in an 'unsigned long long' C equivalent # Representation on 8 octets p_low = n & (2L ** 31 - 1) p_high = (n & (2L ** 64 - 2L ** 32)) >> 32 return struct.pack ('LL', p_low, p_high) def unpack (s) : # Convert an 'unsigned long long' in a 'long' python equivalent p_low, p_high = struct.unpack ('LL', s) return (p_high << 32) + p_low Thanks a lot, Sebastien Dumont. |