java - Convert DWORD byte array to a unsigned long number -
i want unsigned value of little-endian dword byte array.
this wrote:
private long getunsignedint(byte[] data) { long result = 0; (int = 0; < data.length; i++) { result += (data[i] & 0xff) << 8 * (data.length - 1 - i); } return result; }
is right?
no afreaid big endian.
public long readuint(byte[] data) { // if want tackle different lengths little endian: //data = arrays.copyof(data, 4); return bytebuffer.wrap(data) .order(byteorder.little_endian) .getint() & 0xff_ff_ff_ffl; }
the above 4 byte (signed) int conversion , make unsigned.
Comments
Post a Comment