Forum Discussion
Alok_3817
Nimbostratus
May 10, 2010Unit for the Stats pulled by using i Control
Hi,
I am pulling the Global Stats using iControl for 9.4
I get the low and hight values and I create the 64 bit values.... but i am confused as what is the Unit of measurement
Like STATISTIC_CLI...
Hamish
Cirrocumulus
May 27, 2010Posted By Hamish on 05/13/2010 02:19 PM
Yes, your conversion from hi/low 32bit values to 64bit values isn't correct. Use
my $quick64=($statValue->{high}*4294967296)+($statValue->{low}<0?(4294967296+$statValue->{low}):$statValue->{low});
I realised I could expand on that a bit and explain why the code isn't correct (Even though it does look fine, and you'd be quite right in expecting it to work).
The real problem is not you code, it's your version of perl... Or more precisely what the compilation options were that have been specified for integers. The verison you're using has (I suspect) been compiled for 32 bit integers. As the << operation operates by default on unsigned ints (Unless 'use integer' is specified in which case it's signed), you actually get a bitwise left roll implemented... (Why a roll, I'm not sure sorry), which means when the value gets to 2^31, the next 'shift' will actually roll the high order bits back to the low order bits... The code
!/usr/local/bin/perl -W
my $OrigValue=1;
for($i=0; $i<48; $i++) {
my $finalValue=($OrigValue<<$i);
print "$OrigValue << $i ==> $finalValue\n";
}
shows this... Giving the output
bash-3.00 ./shift_check
1 << 0 ==> 1
1 << 1 ==> 2
1 << 2 ==> 4
..[deleted]..
1 << 29 ==> 536870912
1 << 30 ==> 1073741824
1 << 31 ==> 2147483648
1 << 32 ==> 1
1 << 33 ==> 2
1 << 34 ==> 4
1 << 35 ==> 8
1 << 36 ==> 16
1 << 37 ==> 32
Wheras a version that provides 64 bit integers will work as intended... e.g.
bash-3.00 ./shift_check
1 << 0 ==> 1
1 << 1 ==> 2
1 << 2 ==> 4
..[deleted]..
1 << 29 ==> 536870912
1 << 30 ==> 1073741824
1 << 31 ==> 2147483648
1 << 32 ==> 4294967296
1 << 33 ==> 8589934592
1 << 34 ==> 17179869184
1 << 35 ==> 34359738368
1 << 36 ==> 68719476736
1 << 37 ==> 137438953472
Using the value 4294967296 and a multiply, overrides the left shift behaviour and should use floating point math (The perl default)... (Unless you specify 'use integer').
To determine which waqy perl will go, IIRC you need to look at the compile time options... A version that will do 64bit integer math should have a compiletime option of USE_64_BIT_INT specified. A version that doesn't have this will most likely do 32bit (I think it's possible that some OS's will do 64bit anyway IIUC).
e.g. from the two versions I have on an x64 Solaris box...
bash-3.00 /usr/bin/perl -V|grep "Compile-time options:"
Compile-time options: USE_64_BIT_INT USE_LARGE_FILES
bash-3.00 /usr/local/bin/perl -V|grep "Compile-time options:"
Compile-time options: PERL_MALLOC_WRAP USE_LARGE_FILES USE_PERLIO
bash-3.00
H
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