peral king wrote:
I tried as below still its not working (please bear with me as I am completely New to Java)
Some issues...
1. Adding two long variables (using a long) can overflow, and hence, produce data loss. Remember that the value is 16 bytes long, so you need to store it with something that can hold that value... perhaps with a BigInteger?
2. Adding two long variables is *not* how to deal with little endian. With little endian, the low order long
word is first, so you need to shift the high order long word (by 64 bits) before adding it to the low order long word.
3. And you still need to deal with the sign bit. Remember that primitive longs are signed, so it is possible that the low (and the high) long words may be negative. You may have to convert it to a positive (ie. unsigned value) before dealing with the endian.
If this sounds complex, perhaps it is. In fact, I don't even know where to give you a hint... except perhaps to go do some research on endian-ness, and the twos complement format.
Anyway, as Campbell mentioned, since the BigInteger class has support for this (but in Big Endian only), perhaps it is easier to convert the little endian to big endian, and then use the constructor -- no need to understand twos complement.
Henry