Forum Discussion
weikang_Hu_9799
Nimbostratus
Nov 27, 2007Got a negative integer which returned by getLow();
As the structure defined as below . high/low are unsigned integer .
struct Common.ULong64 {
long high;
long low;
};
However, I got a negative integer ..
low= -752457817
high= 1
result = -752457817
my code as below and can someone help me to solve it ?
public long getVSInfo(String[] vs_list) throws Exception
{
String[] Server_Names = m_binding.get_list();
iControl.LocalLBVirtualServerVirtualServerStatistics Statistics_list = m_binding.get_statistics(vs_list);
iControl.LocalLBVirtualServerVirtualServerStatisticEntry[] StatEntry = Statistics_list.getStatistics();
iControl.CommonStatistic[] commonstat=null;
for (int j=0;j{
commonstat= StatEntry[j].getStatistics();
}
long myresult = (commonstat[5].getValue().getHigh()<<32)|commonstat[5].getValue().getLow();
System.out.println(" low= " + (commonstat[5].getValue().getLow()));
System.out.println(" high= " + (commonstat[5].getValue().getHigh()));
System.out.println(" result = " + myresult);
System.out.println("______________________");
//return commonstat[5].getValue().getLow();
return myresult;
}
- Actually, the values are signed, not unsigned. The problem is that when I wrote the original iControl interfaces, java didn't support the XML Schema "unsigned long" type. Maybe that's changed now, but we can't change the interface without breaking backward compatibility. The structure was titled ULong64 but we had to make a type change at last minute and all the interfaces didn't make the change to the Long64 structure.
long myresult = (commonstat[5].getValue().getHigh()<<32)|commonstat[5].getValue().getLow();
- Don_MacVittie_1Historic F5 AccountJoe's code will work fine.... Java now implements longs as 64 bit numbers, and supports unsigned longs, so all should be great if you use his code. My only suggestion would be to declare myresult in his sample as unsigned long instead of long, so you don't get rollover on very large numbers.
- weikang_Hu_9799
Nimbostratus
I do not know how the Java support unsigned long , but I changed my code as below and it seems to be work now. - Don_MacVittie_1Historic F5 AccountHey Weikang,
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