Forum Discussion
Eduardo_Saito_1
Nimbostratus
Sep 25, 2007STATISTIC_BYTES_OUT with negative numbers.
Hello Everybody.
I'm having the following problem and I hope someone can help me.
I did a .net CSharp program that collects STATISTIC_BYTES_IN and STATISTIC_BYTES_OUT.
It really works wh...
Chris_W__13732
Nimbostratus
Jan 30, 2012For 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects