Unsigned long in Java
I needed to get the unsigned value of the bytes in a long. Took some digging, but this finally worked for me:
long longValue;
...// set longValue to something
BigInteger bi = new BigInteger(
Long.toHexString(longValue),16
);
You can then use the methods on BigInteger to get your value. I needed the raw unsigned bytes, so I called bi.toByteArray().
Posted by rickg ( Aug 21 2007, 06:12:23 AM PDT ) Permalink Comments [1]Post a Comment:


Posted by rong (123.116.128.126) on September 24, 2007 at 05:38 PM PDT
Website: http://it-reading.org #