List of utility methods to do Byte Array to Unsigned Int
int | bytesToUint(byte first, byte second, byte third, byte fourth) bytes To Uint int firstI = (first & 0xFF) << 24; int secondI = (second & 0xFF) << 16; int thirdI = (third & 0xFF) << 8; int fourthI = (fourth & 0xFF); return firstI | secondI | thirdI | fourthI; |
long | bytesToUInt(final byte[] bytes, final int position, final int length, final int bitShiftStart, final int bitShitIncrement) bytes To U Int long num = 0; if (length > 4) throw new IllegalArgumentException("The maximum capacity for an int is 32 bytes"); for (int i = 0, bitShift = bitShiftStart; i < length; i++, bitShift += bitShitIncrement) { final long tempVal = bytes[position + i] & 0xff; num += tempVal << bitShift; return num; ... |
int | bytesToUIntLE(byte[] data) bytes To U Int LE return bytesToUIntLE(data, 0, data.length);
|
long | bytesToUIntLong(byte[] bytes, int index) Combines four bytes (most significant bit first) into a 32 bit unsigned integer. long accum = 0; int i = 3; for (int shiftBy = 0; shiftBy < 32; shiftBy += 8) { accum |= ((long) (bytes[index + i] & 0xff)) << shiftBy; i--; return accum; |
int | bytesToUnsignedInt(byte ib1, byte ib2) bytes To Unsigned Int return ((ib1 << 8) + (ib2 & 0xff)) & 0xffff;
|
int[] | bytesToUnsignedInts(byte[] bytes) bytes To Unsigned Ints int[] realvalues = new int[bytes.length]; for (int i = 0; i < bytes.length; i++) { realvalues[i] = bytes[i] & 0xFF; return realvalues; |
int | bytesToUshort(byte b1, byte b2) bytes To Ushort return ((b1 & 0xFF) << 8) + (b2 & 0xFF);
|
short | bytesToUshort(byte first, byte second) bytes To Ushort short value = (short) (((first & 0xFF) << 8) | (second & 0xFF)); return value; |