Forum Discussion

Jitesh_41550's avatar
Icon for Nimbostratus rankNimbostratus
Jul 18, 2011

Convert CommonULong64 to a meaningful value



My goal is to fetch virtual servers/addresses statistics from LTM and display the value on screen. This is effectively mocking the device web console's 'Network Maps'. When queried for stats values of different types are returned in CommonULong64 class which contains two members High and Low. Could someone please guide me on how to convert these two values into one meanigful value (which displays on device web console)?



For ex. High = 2, Low = 477423268 converts to 99.2G



Thanks in advance.




2 Replies

  • Hamish's avatar
    Icon for Cirrocumulus rankCirrocumulus
    Multiply the high value by 2^32 and add it to the low to get a 64bit number. The code will vary depending on language... But in C it would be something like



     unsigned long long result=high<<32+low; 



    (Assumes that the high and low are unsigned integers)



    In perl it'll vary, but you could try



      my $quick64=($statValue->{high}*4294967296)+($statValue->{low}<0?(4294967296+$statValue->{low}):$statValue->{low});



    Remember you need to treat the values as unsigned integers... if you treat them as signed, it'll not work correctly.




  • Hamish's avatar
    Icon for Cirrocumulus rankCirrocumulus
    Oh... The example you give... Is closer to 9.2GB... Not 9.2GB... (2*4G = 8G).