Forum Discussion
mchaas
Nimbostratus
Jan 09, 2009perl - negative value on "low"
Hi!
Hope that this post doesn't appear twice now, I had issues with my browser. If so - my apologies.
I'm having similar problems in perl, where I got the hint at Joe's weblog page:
http://devcentral.f5.com/weblogs/Joe/archive/2005/06/06/553.aspx
But it seems that Math::BigInt in perl doesn't deal with negative low-values either, does it?
Or maybe I am missing something?
Following situation when collecting Virtual Server Statistics, bytesout in this case:
(Code-snip)
$low = $Statsarray[1]->{"value"}->{"low"};
$high = $Statsarray[1]->{"value"}->{"high"};
$bytesout = Math::BigInt->new($high)->blsft(32)->bxor($low);
print "\nLow: " . $low . "\nHigh: ". $high . "\n => " . $bytesout . "\n";
(/Code-snip)
(output)
Low: -2094819476
High: 200411
=> -860760785578132
(/output)
How can I proceed with the low value when it is negative?
Did I get that right: The inverted sign in the low value signals, that high is not 0.
Is it valid to just turn the negative sign into a positive for further calculations?
Thanks in advance and best regards,
Matt
3 Replies
- mchaas
Nimbostratus
Hi again,
No ideas yet?
I looked around on devcentral, all I found out is on
https://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&postid=17128&view=topic
that low is negative when "Numbers that go half way over the 32bit mark, will have the highest bit of 1".
Does it mean that all that happens is that low gets negative as soon as high is not 0?
Can I just multiply the number by -1 and get proper results?
br, Matt - hwidjaja_37598
Altostratus
Try this out:Math::BigInt->new(sprintf("%u",$high))->blsft(32)->bior(sprintf("%u", $low));
Please note:
- bxor is changed to bior
- signed int is converted to unsigned int using sprintf. - mchaas
Nimbostratus
Hi again!
Sorry for the late feedback, was out the country for a while.
Anyway.
Thanks a lot Humphrey, this hint made it!
The values I gather now look quite what they should look like.
br, Matt
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
