List of utility methods to do Byte Array to Int
int | bytesToInt(byte[] b, int offset) bytes To Int int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i + offset] & 0x000000FF) << shift; return value; |
int | bytesToInt(byte[] b, int offset) bytes To Int return (b[offset + 0] & 255) << 24 | (b[offset + 1] & 255) << 16 | (b[offset + 2] & 255) << 8
| (b[offset + 3] & 255);
|
int | bytesToInt(byte[] buf, int offset) Converts a 4 byte array of unsigned bytes to a singed long. int retval = 0; int i = 0; for (; i < 3; ++i) { retval |= buf[i + offset] & 0xFF; retval <<= 8; retval |= buf[i + offset] & 0xFF; return retval; ... |
int | bytesToInt(byte[] buf, int startIdx) bytes To Int return ((0xff & buf[startIdx]) << 24) | ((0xff & buf[startIdx + 1]) << 16)
| ((0xff & buf[startIdx + 2]) << 8) | (0xff & buf[startIdx + 3]);
|
int | bytesToInt(byte[] buff, int off, int len) Utility methods for working with bytes and byte buffers int num = 0; int shift = 0; for (int i = off + len - 1; i >= off; i--) { num += (buff[i] & 0xFF) << shift; shift += 8; return num; |
int | bytesToInt(byte[] bytes) bytes To Int int value = 0; for (int i = 0; i < 4; i++) { int shift = (4 - 1 - i) * 8; value += (bytes[i] & 0x000000FF) << shift; return value; |
int | bytesToInt(byte[] bytes) Converts a byte array to an int. int value = 0; for (int i = 0; i < bytes.length; i++) { int shift = 8 * i; value += (bytes[i] & 0xFF) << shift; return value; |
int | bytesToInt(byte[] bytes) bytes To Int int q3 = bytes[3] << 24; int q2 = bytes[2] << 16; int q1 = bytes[1] << 8; int q0 = bytes[0]; if (q2 < 0) q2 += 16777216; if (q1 < 0) q1 += 65536; ... |
int | bytesToInt(byte[] bytes) Converts a byte array to an int. assert bytes != null && bytes.length <= 4; final int BYTE_SIZE = 8; int value = 0; for (int i = 0; i < bytes.length; i++) { int shift = BYTE_SIZE * i; value += (bytes[i] & 0xff) << shift; return value; ... |
int | bytesToInt(byte[] bytes) Converts a byte array into an integer int result = new Integer((int) (0xff & bytes[0]) << 24 | (int) (0xff & bytes[1]) << 16 | (int) (0xff & bytes[2]) << 8 | (int) (0xff & bytes[3]) << 0); return result; |