Forum Discussion
Chris_W__13732
Jan 30, 2012Nimbostratus
For the benefit of anyone working with python, here's how I conquered this problem...
The problem with python's number handling is that it's near-impossible to get the straight bitwise representation of an int, especially negative numbers. However, since we know these are 32-bit integers, you can undo the two's compliment encoding and go from there.
Unformatted code:
-------
def toLongInt(ulong_64):
"""
F5 likes to hand out 64-bit values as a pair of signed 32s.
Need to undo the two's compliment to get the original
integers back, then "bit-concatenate" them.
"""
high = ulong_64.high
low = ulong_64.low
Convert both values from signed to unsigned
if high < 0:
high = high + (1<<32)
if low < 0:
low = low + (1<<32)
return long((high<<32)|low)
---
Indent-formatted code at http://pastebin.com/p5EUv3Fh