List of utility methods to do Integer Create
int | toInt(byte[] bytes) convert int from byte array int result = 0; for (int i = 0; i < 4; i++) { result = (result << 8) - Byte.MIN_VALUE + (int) bytes[i]; return result; |
int | toInt(byte[] bytes) Creates an integer of the given byte array. if (bytes.length != 4) throw new IllegalArgumentException("The input byte array for a long must have 4 values"); return ((bytes[0] & 0xff) << 24) | ((bytes[1] & 0xff) << 16) | ((bytes[2] & 0xff) << 8) | ((bytes[3] & 0xff)); |
int | toInt(byte[] bytes) to Int int num = 0; if (bytes != null) { for (int i = bytes.length - 1, j = 0; i >= 0; i--, j++) { num += (long) (bytes[i] & 0xff) << (j * 8); return num; |
int | toInt(byte[] bytes, boolean isBigEndian) It will convert <= 4 bytes value to Int int x = 0; int numOfBytes = bytes.length; if (numOfBytes > 4) numOfBytes = 4; for (int i = 0; i < numOfBytes; i++) { if (i == 0) { if (isBigEndian) x = 0xFF & bytes[i]; ... |
int | toInt(byte[] bytes, int index) to Int return (0xff & bytes[index]) | (0xff00 & (bytes[index + 1] << 8)) | (0xff0000 & (bytes[index + 2] << 16))
| (0xff000000 & (bytes[index + 3] << 24));
|
int | toInt(byte[] bytes, int offset) Convert a byte array to an int value int value = 0; if (bytes != null && bytes.length >= 4) { for (int i = 0; i < 4; ++i) { value += (0x000000FF & bytes[offset + i]) << ((3 - i) * 8); return value; |
int | toInt(byte[] bytes, int offset) to Int int ret = 0; for (int i = 0; i < 4 && i + offset < bytes.length; i++) { ret <<= 8; ret |= (int) bytes[i] & 0xFF; return ret; |
int | toInt(byte[] bytes, int offset) to Int if (offset + SIZEOF_INT > bytes.length) { throw new RuntimeException("Cannot decode int from the buffer"); int n = 0; for (int i = offset; i < (offset + SIZEOF_INT); i++) { n <<= 8; n ^= bytes[i] & 0xFF; return n; |
int | toInt(byte[] bytes, int offset) To int. int l = 0; for (int i = offset; i < offset + 4; i++) { l <<= 8; l ^= bytes[i] & 0xFF; return l; |
int | toInt(byte[] data) to Int if (data.length != 4) return 0; return (int) data[0] << 24 | (int) data[1] << 16 | (int) data[2] << 8 | (int) data[3]; |